提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
通过插入将值添加到StringBuffer
public class Main { /**来 自 时代Java - nowjava.com**/ public static void main(String[] args) { boolean b = true; StringBuffer sb1 = new StringBuffer("Hello World"); sb1.insert(6,b); System.out.println(sb1); char c = 'Y'; StringBuffer sb2 = new StringBuffer("Hello World"); sb2.insert(6,c); System.out.println(sb2); char[] c1 = new char[] {'Y','e','s'};/** 来 自 时 代 J a v a 公 众 号**/ StringBuffer sb3 = new StringBuffer("Hello World"); sb3.insert(6,c1); System.out.println(sb3); double d = 12.0; StringBuffer sb4 = new StringBuffer("Hello World"); sb4.insert(6,d); System.out.println(sb4); float f = 12.0f; StringBuffer sb5 = new StringBuffer("Hello World"); sb5.insert(6,f); System.out.println(sb5); int i = 51; StringBuffer sb6 = new StringBuffer("Hello World"); sb6.insert(6,i); System.out.println(sb6); long l = 110; StringBuffer sb7 = new StringBuffer("Hello World"); sb7.insert(6,l); System.out.println(sb7); Object obj = new String("My ttt"); StringBuffer sb8 =