package solution.additionaljavaseclasses; public class UsingStringBuilder { public static void main(String[] args) { StringBuilder sb1 = new StringBuilder(50); sb1.append(""); sb1.append("Johan"); sb1.append("21"); sb1.append(""); System.out.println(sb1); // Delete 21 sb1.delete(25, 38); System.out.println(sb1); // Delete the o and the h in Johan sb1.deleteCharAt(15); sb1.deleteCharAt(15); System.out.println(sb1); // Insert new text sb1.insert(24, "UK"); sb1.insert(24, "M"); System.out.println(sb1); // Replace some text sb1.replace(51, 53, "Wales"); System.out.println(sb1); // Set a specific character sb1.setCharAt(32, 'F'); System.out.println(sb1); String finishedString = sb1.toString(); System.out.println("\nFinished string: " + finishedString); } }