Created
August 31, 2019 12:27
-
-
Save takahashi-h5/564c827055fae8c19c5a4c281279a02a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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