String A in Java; The difference between string a = null and string a = ""

Source: Internet
Author: User

String A; Declares a string type A, which does not have a memory address in the request, nor any point in memory to the reference address;

String a = null; Declare a string of type A, while in memory requested an address, but the address does not point to any reference address;

String a = ""; Declare a string of type A, both in the memory of the application of the address, which also points to a reference to the string reference address;

It is generally best to use string a = "" for strings, and to prevent exceptions that are not found by the subsequent program because of a confusing reference address! String a = null; String A; Use less strength! No need to use it!

String A in Java; The difference between string a = null and string a = ""

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.