已知 sb 为 StringBuffer 的一个实例,且 sb.toString() 的值为 "abcde ", 则执行sb. reverse()后,sb.toString()的值为【】
举一反三
- class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("abcd"); sb.reverse(); System.out.println( sb.toString() ); } } 代码的输出结果是: dcba
- 下面代码段输出的结果是( )StringBuffer sb = new StringBuffer("huangjianfeng");sb.delete(1,3);System.out.println(sb.toString()); A: ngjianfeng B: hgjianfeng C: hngjianfeng D: hjianfeng
- 分析下面的Java程序段,编译运行后的输出结果是( )。public class Test {public void changeString(StringBuffer sb) {sb.append("stringbuffer2");}public static void main(String[] args) {Test a = new Test();StringBuffer sb = new StringBuffer("stringbuffer1");a.changeString(sb);System.out.println("sb = " + sb);}} A: sb = stringbuffer2stringbuffer1 B: sb = stringbuffer1 C: sb = stringbuffer2 D: sb = stringbuffer1stringbuffer2
- class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("jack"); sb.append(true); sb.append('a'); sb.append(97).append(34.0).append(new char[]{'A','B'}); // 链式编程 System.out.println( sb.toString() ); // 输出缓冲区的中文本数据 sb = new StringBuffer("jack"); sb.insert( 2, "java" ); System.out.println( sb.toString() ); } } A: jacktruea9734.0AB jjavaack B: jacktruea9734.0AB jajavack C: jacktrueaa34.0AB jajavack D: jacktruea9734AB jajavack
- class Test { public static void main(String[] args) { StringBuffer sb = new StringBuffer("hello world"); sb.delete(6,sb.length()); System.out.println( sb.toString() ); } } A: Hello w B: Hello C: Hello worl