下列输出结果为false的是( ) String s1 = new String("SUN"); String s2 = new String("SUN");
A: System.out.println(s1 == s2);
B: System.out.println(s1.equals(s2));
C: System.out.println(s1 = s2);
D: System.out.println(s1.equals("SUN"));
A: System.out.println(s1 == s2);
B: System.out.println(s1.equals(s2));
C: System.out.println(s1 = s2);
D: System.out.println(s1.equals("SUN"));
举一反三
- 以下程序的输出结果是 String s1="1",s2="2"; String s=s1+s2; System.out.println(s);
- 请说出下列代码的执行结果 : String s = "abcd"; String s1 = new String(s); if (s = = s1) System.out.println("the same"); if (s.equals(s1)) System.out.println("equals");
- (10-8)关于以下程序段,正确的说法是( )。 1 String s1=”ac”+”def”; 2 String s2=new String(s1); 3 if(s1.equals(s2)) 4 System.out.println(“equals() succeeded”); 5 else if(s1==s2) 6 System.out.println(“== succeeded”);
- 中国大学MOOC: 写出程序段输出结果:String s1=new String(abc);String s2=abc;System.out.print((s1==s2)+,);System.out.println(s1.equals(s2));
- 下列代码片段执行结果是:String s=new String(”abc”); String s1=new String(s); if(s==s1){ System.out.println(”Hello”); } if(s.equals(s1)){ System.out.println(”World”); } A: Hello World B: Hello C: World D: Null