Fifth Chapter String
5.1 String Class
5.1.1 Declaration String
String Str=[null]
5.1.2 Creating a String
String (char a[] method);
String (char a[],int offset,int length);//parameter offset indicates the position at which the string is to be truncated, and length indicates how long it is to intercept the string
String (Char[].value)//The construction method allocates a new string object that represents the result of the connection of all elements in the character array parameter;
5.2 Connection string
5.2.1 Connecting multiple strings
The "+" operator can concatenate multiple operators and produce a string class object
5.2.2 Connecting other data types
Strings are concatenated with other data type data through the "+" operator, which translates the data directly into strings;
5.3 Getting string information
5.3.1 Get string length
Str.length ();//str is a String object
5.3.2 String Lookup
IndexOf (string s)//returns the index position of the first occurrence of the parameter string s in the specified string
LastIndexof (string s)//returns the position of the last occurrence of the argument string s in the specified string
5.3.3 gets the character at the specified index position
Str.charat (int index)//index: integer value that specifies the subscript to return the character
5.4 String manipulation
5.4.1 Getting substrings
substring (int begininiindex)//Returns the character starting at the specified index position to intercept until the end of the string;
substring (int beginindex,endlindex)//a substring that is intercepted at an index position from a string at the end of an index
5.4.2 Removing spaces
Str.trim ()//str is an arbitrary string object
5.4.3 string substitution
Str.replace (char Oldchar,char Newchar)//oldchar: The character or string to replace; Newchar: Used to replace the contents of the original string;
5.4.4 to determine the beginning and end of a string
Str.startswith (String suffix)//suffix refers to the character that is prefixed;
Str.endswith (String suffix)//suffix refers to the character being suffixed; (both return values are Boolean)
5.4.5 determine if strings are equal
Str.equals (String otherstr)//str and Otherstr are two string objects that participate in comparisons (case-sensitive)
Str.equalslgnorecase (String otherstr)//Case insensitive
5.4.6 comparison of two strings in dictionary order
Str.compareto (String otherstr)//in dictionary order str Sun Xu returns a negative integer before the parameter string, and then returns a positive integer, equal to zero
5.4.7 Letter Case Conversion
Str.tolowercase ()//str is the string to be converted
Str.touppercase ()
5.4.8 String Segmentation
Str.split (string sign)//sign as a split-string delimiter
Str.split (String sign,int limit)//limit Limit number of splits
5.5 Formatting strings
Str.format (String Foamat,object...args)//format: Formatted string, args: The parameter referenced by the format specifier in the formatted string;
5.5.1 Date and time string formatting
1. Date formatting
2. Time formatting
5.5.2 General type formatting
Implemented by regular conversion characters
5.6 Using regular Expressions
A regular expression is a string of characters with special meanings, which are called metacharacters of regular expressions;
5.7 String Generator
String-builder class
"Java from Beginner to Mastery" chapter fifth