[Java] The difference between String and String()

String s1="a,d";
String s2="b";
String s3="c";
String[] s4 = new String[3];
s4[0]=s1;
s4[1]=s2;
s4[2]=s3;	
for(int i=0;i<s4.length;i++) {
    
    
	System.out.print(" "+s4[i]);
}

The output result is a, dbc

According to the above example, String is a single string, which can contain multiple characters, and String[] is an array of string numbers, which can contain multiple strings.

Therefore, String is an object that declares a string, and can only store one string. String[] contains many Strings.

Guess you like

Origin blog.csdn.net/qq_16488989/article/details/109292644