Initialization of the Java string type

Source: Internet
Author: User

The following is basically the three most common method of Java string Type new string () does not describe the basic equivalent of the third

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 = "";
You can prevent subsequent programs from being unable to find an exception because of a confusing reference address!
String a = null;  String A;  Try to use less! No need to use it!

Initialization of the Java string type

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.