APIs: (Application programming Interface, programming interfaces) are pre-defined functions designed to provide the ability of an application and developer to access a set of routines based on a piece of software or hardware without having to access the source code or to understand the details of the internal working mechanism.
String strings:
The string class is described in Java. Encapsulates the object with a string. The advantage is that you can easily manipulate the common data of strings. After the object is encapsulated, you can define n multiple properties and behaviors.
How do I define a string object? String s = "abc";any data that is caused by double quotation marks is a string object.
Characteristics:once the string is initialized, it cannot be changed and stored in a constant pool in the method area.
------------------------------------------------------
String S1 = "abc";//S1 points to only one object in memory ABC.
string s2 = new String ("abc"), and//s2 points to a content that has two object ABC, new.
System.out.println (S1==S2);//false = = The address value is compared
System.out.println (s1.equals (S2));//true, equals in the string compares the contents of the strings.
In object, equals compares the address values of two objects, whether they are the same.
Search API.
-------------------------------------------------------
Method of String:
1: Converts a byte array or an array of characters into a string.
string S1 = new string ();//A string that creates an empty content。
String s2 = null;//S2 does not have any object pointing, it is a null constant value.
String s3 = "";//S3 points to a specific string object, except that there is no content in the string.
Generally, when you define a string, you do not need new.
String S4 = new String ("abc");
String s5 = "abc";
New String (char[]);//Converts a character array into a string.
New String (char[],offset,count);//Converts a portion of a character array into a string.
2: General Method:
2.1 Get:
2.1.1: Gets the length of the string. Length ();
2.1.2: The character at the specified position. char charAt (int index);
2.1.3:gets the position of the specified character. If there is no return-1, you can use the return value-one to determine if a character does not exist.
int indexOf (int ch);//returns the first-time character corner label found
int indexOf (int ch,int fromIndex); //returns the first time a corner label was found at the beginning of the specified position
int indexOf (String str); //returns the first string corner label found
int indexOf (String str,int fromIndex);
int lastIndexOf (int ch);
int lastIndexOf (int ch,int fromIndex);
int lastIndexOf (String str);
int lastIndexOf (String str,int fromIndex);
2.1.4: Gets the substring.
String substring (int start);//starting at the start bit, until length ()-1.
String substring (int start,int end);//from start to end. Contains the start bit, and does not contain an end bit.
SUBSTRING (0,str.length ());//get the whole string
2.2
2.2.1: Does the string contain the specified string?
Boolean contains (String substring);
2.2.2: Does the string start with the specified string?
Boolean StartsWith (String);
2.2.3: Does the string end with the specified string?
Boolean EndsWith (String);
2.2.4: Determine if strings are the same
Boolean equals (string);//Overrides the method in object to determine whether the contents of the string are the same.
2.2.5: Determines whether the string contents are the same, ignoring case.
Boolean equalsignorecase (String);
2.3
2.3.1: You can convert a character array or a byte array into a string by using a constructor function.
2.3.2: You can convert a character array to a string by using a static method in the string.
Static String copyvalueof (char[]);
Static String copyvalueof (Char[],int offset,int count);
Static String valueOf (char[]);
Static String valueOf (Char[],int offset,int count);
2.3.3: Converts the base data type or object into a string.
Static String valueOf (char);
Static String ValueOf (Boolean);
Static String valueOf (double);
Static String valueOf (float);
static String valueOf (int);
Static String valueOf (long);
Static String valueOf (Object);
2.3.4: Turns the string to case.
String toLowerCase ();
String toUpperCase ();
2.3.5: Converts a string to an array.
Char[] ToCharArray ();//turn into a character array.
Byte[] GetBytes ();//Can be added to the encoding table. Turns into a byte array.
2.3.6: Converts a string into an array of strings. Cutting method.
String[] Split (split rule-string);
2.3.7: Replace the string with the content. Note: Changing to a new string does not modify the original string directly.
String replace (Oldchar,newchar);
String replace (oldstring,newstring);
2.3.8:string concat (String); Appends a string.
string trim ();//remove spaces at both ends of the string
int CompareTo ();//If the argument string equals this string, the value 0 is returned, and if the string is less than the string parameter in dictionary order, a value less than 0 is returned, and if the string is greater than the string parameter in dictionary order, a value greater than 0 is returned.
Java Fundamentals---API