Sololearn: Learn to Code
+ 11
● String is not a primitive data type like int, char etc . Its a Class in java lang package (& class name starts with capital by naming convention in java to make code more readable). //see this : intializing of a String , like a String object : String hy = new String("hello");
2nd Jan 2019, 4:26 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 6
In java, string is not actual data type. It is reference data type of a class. Maybe that's why first letter of String is always capital. Not sure tho.
2nd Jan 2019, 1:44 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 5
"Unlike C/C++, where string is simply an array of char, A Java String is an object of the class java.lang." http://www.ntu.edu.sg/home/ehchua/programming/java/j3d_string.html
2nd Jan 2019, 1:34 AM
Alyson Jorge
Alyson Jorge - avatar
+ 5
Its because Strings are special they are objects. And becuase of this you can access its properties like str.length which will return the length of your String, you cant do this with primitive types.
2nd Jan 2019, 2:08 AM
D_Stark
D_Stark - avatar