String的定义不同导致的不一致

来源:互联网 发布:淘宝详情页一整张上传 编辑:程序博客网 时间:2024/04/30 07:30
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


原创粉丝点击