/* This program demonstrates some of the methods available in the StringBuilder class. * The StringBuilder is a mutable String class available in the java.lang library. * It is usefule wehn we want to have a string that changes frequently. */ import java.util.Scanner; class MyStrings { public static void main(String [] args) { Scanner input = new Scanner(System.in); //create a new StringBuilder with the text "Doge" StringBuilder buf1 = new StringBuilder("Doge"); //print length and capacity System.out.println("Size: "+buf1.length()+"\tCapacity: "+buf1.capacity()); //append buffer with more text buf1.append(" Such String much text very wow."); System.out.println("Size: "+buf1.length()+"\tCapacity: "+buf1.capacity()); //insert text starting from position 10 buf1.insert(10, "many many memes"); System.out.println(buf1); System.out.println("Size: "+buf1.length()+"\tCapacity: "+buf1.capacity()); //reverse the text buf1.reverse(); System.out.println(buf1); System.out.println("Size: "+buf1.length()+"\tCapacity: "+buf1.capacity()); } }