Skip to content

Instantly share code, notes, and snippets.

@jayden-lee
Last active October 16, 2018 15:05
Show Gist options
  • Save jayden-lee/222dbf1e161765c5e03c23761a0df4b8 to your computer and use it in GitHub Desktop.
Save jayden-lee/222dbf1e161765c5e03c23761a0df4b8 to your computer and use it in GitHub Desktop.
"" 또는 생성자를 이용한 Java 문자열 생성
String s1 = "Hello, gglee";
String s2 = new String("Hello, gglee");
String c = new String("abcd");
String d = new String("abcd");
System.out.println(c == d); // false
System.out.println(c.equals(d)); // true
String c = new String("abcd").intern();
String d = new String("abcd").intern();
System.out.println(c == d); // true
System.out.println(c.equals(d)); // true
String a = "abcd";
String b = "abcd";
System.out.println(a == b); // true
System.out.println(a.equals(b)); // true
String a = "abcd";
String c = new String("abcd").intern();
System.out.println(a == c); // true
System.out.println(a.equals(c)); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment