Code Fix

上級オートボクシングで起きる NullPointerException › パターン1

オートボクシングで起きる NullPointerException

Integerはnullを持てますが、演算時にintへ開封されます。

 1  public class Main {
 2      public static void main(String[] args) {
 3          _______ n = null;
               ^
 4          System.out.println(n + 1);
 5      }
 6  }
Exception in thread "main" java.lang.NullPointerExceptionexited with code 1

空欄を埋めてビルドを通す

広告
広告スロット(未設定)

オートボクシングで起きる NullPointerException

Map.getの戻り値の受け方を扱います。

このエラーの解説と類題をまとめて見る →

広告
広告スロット(未設定)