原来一直理解错了intern,建议可以把案例改成这个
H-Kcloud opened this issue · comments
public class Intern {
public static void main(String[] args) {
String s = new String("2");
String s2 = "2";
s.intern();
System.out.println( s == s2); // false
System.out.println( s.intern() == s2); // true
}
}
感谢,后面考虑加上
收到,感谢反馈
| |
anotherpony
|
|
***@***.***
|
签名由网易邮箱大师定制
在2021年9月2日 ***@***.***> 写道:
public class Intern {
public static void main(String[] args) {
String s = new String("2");
String s2 = "2";
s.intern();
System.out.println( s == s2); // false
System.out.println( s.intern() == s2); // true
}
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.