Java — Method Chaining in String, StringBuffer & StringBuilder | Code Factory

Index Page : Link

Donate : Link

String s = new String("    Code Factory  ").replace("o", "O").trim();
System.out.println(s);
StringBuffer sb = new StringBuffer("Code Factory").replace(4, 5, "-").append(123);
System.out.println(sb);
StringBuilder sbl = new StringBuilder("Code Factory").replace(4, 6, "-").delete(10, 11);
System.out.println(sbl);

Output :

COde FactOry
Code-Factory123
Code-actor