Code Fix

中級== と .equals() の違い(文字列比較) › パターン3

== と .equals() の違い(文字列比較)

Java初学者が最も多く踏む罠。

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

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

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

== と .equals() の違い(文字列比較)

参照比較と値比較の違い、定数プール、null安全な書き方まで扱います。

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

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