Multithreading to the beginning of the common object API involved, back also to back down!!!
Future development, meet the most object is the text, that is, the string
String class
A string is a special object
Once the string is initialized, it cannot be changed.
First, the characteristics
public class Main {public static void main (string[] args) {Demo1 (); System.out.println ("--------------");D Emo2 ();} /* Demonstrates the first definition of a string and defines the character of the string constant pool */private static void Demo1 () {string S1 = "ASD"; s1 = "SD";//s1 is just a reference to the string, and the string "ASD" itself is not variable string S2 = new String ("SDF"); System.out.println (s1); s2 = "SD"; System.out.println (S2==S1);//s1 and S2 actually point to the same address value//sd stored in the buffer (string constant pool)//If not, create a second definition of the}/* demo string without creating it, */public static void Demo2 () {String s = "abc";//Creates an object in a string constant pool string S1 = new String ("abc");//not created in the string constant pool, create object two objects in heap memory//one is S1 a "ABC" System.out.println (s = = S1);//false, the address value of the comparison is not the same System.out.println (S.equals (S1));//true/* equals in the String class has a copy of equals in object that establishes the string class * its own judgment string object is the same * that is, compare string content */system.out.println ("s =" +s); System.out.println ("S1 =" +s1);}}
Second, the structure function
public class Main{public static void Main (string[] args) {StringconstructorDemo1 (); Chardemo ();} public static void StringconstructorDemo1 () {string s = new string ();//equivalent to string s = ""; Address value not equal, string s = nullbyte[] s UB = {97,66}; string S1 = new String (sub); System.out.println ("S1 =" +s1);} public static void Chardemo () {char[] ch = {' A ', ' B ', ' C ', ' d ', ' e ', ' f '}; String string = new string (ch);//converts the array into a string, only Byte and charSystem.out.println ("string =" +string); String string1 = new string (ch,0,3);//3 characters System.out.println from 0 corners ("string1 =" +string1),//string class remaining method, check manual}
Not finished ....
Java Learning Lesson 28th (Common Object API)-String class