cosen1024 / Java-Interview

「Java面试小抄」一份通向理想互联网公司的面试汇总,包括 Java基础、Java并发、JVM、MySQL、Redis、Spring、MyBatis、Kafka、计算机操作系统、计算机网络、系统设计、分布式、Java 项目实战等

Home Page:https://www.javalearn.cn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

原来一直理解错了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
}
}

感谢,后面考虑加上