Skip to content

Instantly share code, notes, and snippets.

@takahashi-h5
Created August 31, 2019 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takahashi-h5/564c827055fae8c19c5a4c281279a02a to your computer and use it in GitHub Desktop.
Save takahashi-h5/564c827055fae8c19c5a4c281279a02a to your computer and use it in GitHub Desktop.
public class Main {
public static void main(String[] args) {
String str1 = "aa";
String str2 = new String("aa"); // newすると別インスタンスになる
System.out.println(str1 == str2); // 同一インスタンスではないため、false
System.out.println(str1.equals(str2)); // 同値のため、true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment