StringBuffer s = newStringBuffer("happynewyear");s1 = s.substring(5,8);System.out.println(s1);程序输出结果为()
A: ynew
B: new
C: ewy
D: happy
A: ynew
B: new
C: ewy
D: happy
举一反三
- 请说出下列代码的执行结果 : String s = "abcd"; String s1 = new String(s); if (s = = s1) System.out.println("the same"); if (s.equals(s1)) System.out.println("equals");
- 以下程序的输出结果是 String s1="1",s2="2"; String s=s1+s2; System.out.println(s);
- 下列代码片段执行结果是: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
- StringBuffer s1=new StringBuffer('Hello World'); System.out.println(s1.append('Tom')); 输出结果为Hello WorldTom。
- StringBuffer s1=new StringBuffer("Hello World");System.out.println(s1.insert(3, "aa"));输出结果为Helaalo World。