String s3 = "hello";
String s4 = "hello";
System.out.println(s3 == s4); //true,这种String位于DateSegment,相同内容会指向同一对象
String s5 = new String("hello");
String s6 = new String("hello");
System.out.println(s5 == s6); //false
String的定义不同导致的不一致
最新推荐文章于 2022-01-22 01:36:10 发布