LoginSignup
0
0

More than 1 year has passed since last update.

よくやるNullPointerExceptionまとめ

Last updated at Posted at 2021-09-01

基本的すぎることですがよくやるのでメモ

定数.equals(変数)で変数がnull

final String nullStr = null;

// ぬるぽにならない
System.out.println("a".equals(nullStr));
// ぬるぽになる
System.out.println(nullStr.equals("a"));

if文がnull

final String nullStr = null;
// ぬるぽ
if (nullStr) {}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0