public class String_constructor {
Shortcut key Small method: Ctrl+d, delete the whole line, select a few lines to delete a few lines
public static void Main (string[] args) {
String S=new string ();//string s= ""; This 2 is the same meaning, equivalent.
Although the address is not the same, but the content is the same, is to construct a string. String S=null; This is not the same, this means that the constant value is null
//
///*
* Converts a byte array into a string
// * */
byte [] arr={65,66,67,68};
String S1=new string (arr);
System.out.println ("s1=" +s1);//abcd, will he assi the numbers? The value is looked up, and a byte array is converted into a string.
/*
* String construction method inside the API help document
* String (char[] value) assigns a new string that represents the sequence of characters currently contained in the character array parameter. (Array of strings)
*
*
* */
Char [] arr={' w ', ' A ', ' P ', ' Q ', ' X '};
String S=new string (arr,1,3),//starting from the 1-point index of the array, taking 3 (starting from 0)
System.out.println (s);
}
}
Object-Oriented 15.2String class-constructor