Overview: 1. after JDK1.5, StringBuilder is displayed, a variable string sequence 2. the usage of StringBuffer is basically the same, 3. the difference between StringBuilder and StringBuffer lies in that StringBuffer is thread-safe. when a single thread and no thread security are required, the StringBuilder [java] package com. cxy. e; public class StringBuilderTest {public static void main (String [] args) {StringBuilder s = new StringBuilder (); // append s. append ("cxy "). append ("show"); System. out. println (s); // insert s. insert (3, "begin"); // insert the begin string System after sequence 3. out. println (s); // Delete s. delete (3, 3 + "begin ". length (); // Delete the begin string inserted above System. out. println (s); // String Length and capacity System. out. println ("String Length:" + s. length (); System. out. println ("string capacity:" + s. capacity (); System. out. println ("the character whose serial number is 1 in the string is:" + s. charAt (1); s. append ("StringBuilder"); System. out. println (s); System. out. println ("I first appeared position number:" + s. indexOf ("I"); System. out. println ("I last position:" + s. lastIndexOf ("I"); // replace s. replace (, "test"); // replace the content from number 4 to number 8 with test System. out. println (s); System. out. println ("reverse string output:" + s. reverse (); s. reverse (); // string truncation System. out. println ("extract content ranging from 4 to 8:" + s. substring (4, 8); // convert to String System. out. println (s. getClass (). getSimpleName (); System. out. println (s. toString (). getClass (). getSimpleName ());}}