learning java StringBuilder 类
StringBuilder s1 = new StringBuilder(); s1.append("panzidong"); s1.insert(0,"hong,"); s1.replace(4,5,"!"); s1.reverse(); System.out.println(s1); System.out.println(s1); System.out.println(s1.length()); System.out.println(s1.capacity()); s1.setLength(4); System.out.println(s1);
output:
gnodiznap!gnoh gnodiznap!gnoh 14 16 gnod