1.String s1 = new String("hello"); 2.String s2 = new String("hello"); 3.System.out.println(s1==s2):

来源:学生作业帮助网 编辑:作业帮 时间:2024/06/17 00:28:42
1.String s1 = new String(
x)3 .)KW(6TUK-W52Rsr4Jp)1 ,.I/-+JiiZ$;f'x9}E3N\db̧ /}~}z>y6c=sS u?0(t>mk}n;Ny ٜ5/v2=]4ϧ(6K-,tӎ@%Ez6yvIq

1.String s1 = new String("hello"); 2.String s2 = new String("hello"); 3.System.out.println(s1==s2):
1.String s1 = new String("hello"); 2.String s2 = new String("hello"); 3.System.out.println(s1==s2):

1.String s1 = new String("hello"); 2.String s2 = new String("hello"); 3.System.out.println(s1==s2):
呃,什么问题呢?这几句话输出的结果是:false.s1,s2指向的对象内容相同,但是本身是不同的.如果使用s1.equals(s2),则是true.