StringBuilder sb = new StringBuilder("Hello"); sb.append(" World"); System.out.println(sb.toString()); // Output: "Hello World"
StringBuilder sb = new StringBuilder(); sb.append("Name: ").append("John").append("\n"); sb.append("Age: ").append(25).append("\n"); sb.append("Salary: $").append(50000.00); System.out.println(sb.toString()); /* Output: Name: John Age: 25 Salary: $50000.0 */
StringBuilder sb = new StringBuilder("Hello World"); sb.delete(5, 11); System.out.println(sb.toString()); // Output: "Hello"The StringBuilder class is part of the java.lang package library.