String a= "B" with string C=new string ("B");

Source: Internet
Author: User

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");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.