Java-Interview icon indicating copy to clipboard operation
Java-Interview copied to clipboard

原来一直理解错了intern,建议可以把案例改成这个

Open H-Kcloud opened this issue 4 years ago • 2 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 } }

H-Kcloud avatar Sep 02 '21 02:09 H-Kcloud

感谢,后面考虑加上

cosen1024 avatar Sep 04 '21 07:09 cosen1024

收到,感谢反馈

| | 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.

cosen1024 avatar Oct 17 '21 12:10 cosen1024