1.String
The string class is the final class and there can be no child classes
PackageCom.demo.pkg1; Public classteststring { Public Static voidMain (string[] agrs) {//construct a stringString name = "Hello World"; String S1=NewString ("AAA"); //length intx =name.length (); //character position Charc = Name.charat (3); //Sub-stringString s = name.substring (5,8); //Remove SpacesString SS =Name.trim (); SYSTEM.OUT.PRINTLN (x); System.out.println (c); System.out.println (s); SYSTEM.OUT.PRINTLN (ss); }}
e lo Hello World
2.StringBuffer (variable)
Public class teststring { publicstaticvoid main (string[] agrs) { new stringbuffer ("Hello"); S.append (// String Type no append System.out.println (s); // turn into a string }}
Hello World
3.StringBuilder
StringBuilder thread is unsafe, stringbuffer thread safe. Single threaded use of StringBuilder can be a bit faster.
Java Learning----String functions