String
String str = "ABC"; (String constants)
str = "Def"; (point to new String)
String str1 =new string ("Tom");
String str2 =str1;
STR1 = "Rose"; (Assigning a new string address to str1)
Output results
Char[] c= {' A ', ' B ', ' C '}
String Str3 =new string (c) (converts other types to strings)
Output
The length of the output STR3 str3.length band () is the method
STR1 = "ABC";
STR2 = "ABC";
Output = = true (= = Compare memory address)
STR1 =new String ("abc")
STR2 =new String ("abc")
Output = = False
Output (Str1.equals (STR2)); (Compare content equality)
Determine the beginning and end of a string
Output (Str1.startswith ("AB"));
Output (Str1.endwith ("C"))
Find the index value of a string
str1 = "Lkjhgfdsaqqqqqwertyuiop";
Output (Str1.indexof ("a")); (Find the index of a, no matter how many A is the first one from left to right)
Output (Str1.lastindexof ("a")); (in contrast to the above, find the first one from right to left)
Get substring
Str1.substring (Start end)
Output (str 1.charAt (1));
Replace
Str1.replace ("FD", "FD") (returns the replaced string)
Output ()
Go to Space
STR1 = "# tom #";
Output (Str1.replace ("", "")) (go to all spaces)
Output (Str1.trim ()); (Remove the front and back spaces only)
Str.replacceall ("", ""); (supports regular expressions)
Split using a specific delimiter, bar string Segmentation array
str1 = "abc#) def#) 123#) GGG";
String[] St=str.split ("#)");
Output (st.length);
Output (st[0]);
Variable character sequence
StringBuilder strb =new StringBuilder ("abc")
Strb.append ("Def")
Strb.append ("VB")
Strb.append ("AA")
Strb.append ("Def"). Append ("VB"). Append ("AA") (Another way)
StringBuffer stru =new stringbuffer ("Sdsds")
Stru.append ("SDFD")
String STR4 =stru.tostring ();
Output ()
Hand-Punched notes