String is under the Java.lang package, with several methods: calculating string lengths, comparing strings, connection strings, extracting strings, etc.
1. Determine the length of the string: Use the Length () method
2. Comparison string: The Equals () method is provided to compare whether the content stored in the two string object is the same (only in the string)
The difference between "= =" and equals: "= =" is compared to the address, equals is the content
Ignore case comparison: Use Equalsignorecase () method toLowerCase () to lowercase touppercase () to uppercase
3. Connection string: (1) use "+"
(2) Concat () method eg:string s = "Hello,"; String name = "Zhang San"; String ss = S.concat (name);
4. Extracting strings: Common methods of extraction: indexOf (int ch), indexOf (string value) search for the first occurrence of the position (or string value)
lastIndexOf (int ch), lastIndexOf (string value) searches for the last occurrence of the position (or string value)
SUBSTRING (beginindex,endindex+1) method extracts a string from Beginindex to endindex+1 location
String[] s = phone.split (string s) method to split a string into substrings
The method that is in the string