java on common String Method 2

1.String constant address value:

 

 

2.

API midst, and said: All string literals (such as "abc") Java program as an instance of this class are realized. 
In fact, that is: the program among all double-quoted strings, is an object of the String class. (Even if not new, it still yes.)

3.
Features of the string: 
Contents 1. Never string variable. [Emphasis]
2. It is precisely because the string can not be changed, so the strings can be shared use.
3. The effect is equivalent to a string char [] array of characters, but the underlying principle is the byte [] array of bytes.
Note: Direct write double quotes is the string object.

4.
Create a common 3 + 1 Ways string.
Method three configurations:
public String (): Create a blank string does not contain any content.

 

 

 

public String (char [] array): The contents of the character array to create the corresponding character string.

 

 

public String (byte [] array): The contents of the byte array to create the corresponding character string.

 

 

String str = "Hello"; // use double quotation marks directly on the right

 

 

 

 

 

 

 
 
 



Guess you like

Origin www.cnblogs.com/suitang/p/11568287.html