• 2021-04-14
    StringBuffer s1=new StringBuffer('Hello World');
    System.out.println(s1.append('Tom'));
    输出结果为Hello WorldTom。
  • 内容

    • 0

      class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("hello world"); sb.replace(6, sb.length(), "java"); System.out.println( sb.toString() ); } } 选择正确的运行结果 A: hello javad B: hellojava C: hello java

    • 1

      StringBuffer s = newStringBuffer("happynewyear");s1 = s.substring(5,8);System.out.println(s1);程序输出结果为() A: ynew B: new C: ewy D: happy

    • 2

      调用以下类D和E的main() 方法的输出结果为?class D { public static void main(String[] args) { String s1 = new String("hello"); String s2 = new String("hello"); if (s1.equals(s2)) System.out.println("equal"); else System.out.println("not equal"); }} class E { public static void main(String[] args) { StringBuffer sb1 = new StringBuffer("hello"); StringBuffer sb2 = new StringBuffer("hello"); if (sb1.equals(sb2)) System.out.println("equal"); else System.out.println("not equal"); }} A: D: equal; E: equal B: D: not equal; E: not equal C: D: equal; E: not equal D: D: not equal; E: equal

    • 3

      已知定义字符串s,其格式为StringBuffer s=new StringBuffer(“hello”).若要朝s中尾部追加一串字符串,应调用StringBuffer类中的______________方法。

    • 4

      执行StringBuffer s = new StringBuffer("abc"); s.insert(1,"Good"); s的正确结果是()