The Java string is a class where the Java virtual machine instantiates 9 object pools at startup, 9 of which are used to store 8 basic data types (Int,float,double,byte,boolean,short,long, Char) wrapper class and string object.
Java String creates objects in two ways, one of which is by creating directly: String str1= "Stringhello" and the other through constructors: string Str2=new string ("Stringhello"); The former is an object that is directly generated by taking objects in the object pool. String str3= "111"; String str4= "111"; System.out.println (STR3==STR4);==>> output is: true. This is because both STR3 and STR4 are obtained through the object pool, however, by string Str5=new string ("111"); System.out.println (STR3==STR5);==>> output is: false. This is because STR3 is obtained through the object pool, and STR5 is created directly, so the nature is different;
= =: This comparison method refers to the same nature is true, and the equal () method requires only the same value.
Java String Object Pool