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

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);
COde FactOry
Code-Factory123
Code-actor

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store