One, String class
1. String is a class that is located in the Java.lang package
2.2 ways to create a string object:
String Variable name = "Value";
String Object name =new string ("value");
3. Common methods of string
3.1 String length--length ()
3.2 Determine if the values are equal equals ()
3.3 Determine if the string object address is the same = =
3.4 Ignore case judgment equalsignorecase ()
3.5 Case Conversion
toLowerCase ()--lowercase
toUpperCase ()--uppercase
3.6 Ways to concatenate strings
Method 1: Use the + sign
Method 2: String variable. concat (The string to concatenate);
3.7 Common methods for string extraction
The same method, with multiple representations-method overloading
3.7.1 indexOf (character or string), where the first occurrence of a character or string is found;
Returns a number, 1 means no, returns a number that is >=0, indicating the presence
3.7.2 lastIndexOf (character or string) to find the last occurrence of a character or string;
Returns a number, 1 means no, returns a number that is >=0, indicating the presence
3.7.3 substring () method
L substring (extract position): Indicates the end of extraction from the beginning of the fetch position to the end of the string
L substring (start position, end position): a substring that extracts from the start position to the end position-1 [the end position is greater than the length of the entire string, an exception occurs]
3.8 Trim ()--remove whitespace from the left and right sides of the string
3.9 String Split--split () returns an array of strings
Second, StringBuffer class
1. What is the difference between StringBuffer and string?
String space or length is fixed, stringbuffer space variable
String efficiency less than StringBuffer class
2. What are the steps of using the StringBuffer class?
Step 1: Create the object first
StringBuffer Object name =new stringbuffer ();
StringBuffer Object name =new stringbuffer (default value);
Step 2: Append or Insert values to the object
StringBuffer object name. Append (appended value);//can append any value (Char,int, etc.)
StringBuffer the object name. Insert (the position to insert, the value inserted);
Java Fundamentals (Chapter 15)