1 PackageFengke.hashcode;2 /**3 * 4 * @authorFeng Ke5 * Study notes:6 *1.hashcode is not a memory address, but a memory address;7 *2.== determines the memory address8 *3.equals is generally overridden by reference types such as String, not comparing memory addresses, but actually representing the difference in content;9 when a class is called, the contents of static are loaded first;Ten * One */ A - Public classstringandnewstring { - //storage in a constant pool (no duplicates); the PublicString a= "Feng Ke"; - //build data in the heap - PublicString b=NewString ("Feng Ke"); - PublicString c=A; + - + A Publicstringandnewstring () { atSYSTEM.OUT.PRINTLN ("No parameter constructor called"! "); - } - - Public Static voidMain (string[] args) { -SYSTEM.OUT.PRINTLN ("No parameter constructor is called! "); -Stringandnewstring test=Newstringandnewstring (); inSystem.out.println ("called static! "); - System.out.println (Test.a.hashcode ()); to System.out.println (Test.b.hashcode ()); + System.out.println (Test.c.hashcode ()); -System.out.println (test.a==test.b); the } *}
String a= "B" with string C=new string ("B");