I was wondering, why is it "String" and not "string" when all other primitive data types are lowercase?
8 Answers
String isn't a primitive datatype - it's a class, a reference type. Now admittedly it's supported directly in the VM, and there are literals in the language - but it's still not a primitive type.
2 Comments
byte[] array: {'v', 'a', 'l', 'u', 'e'}It's not a primitive, the String class is an object.
http://download.oracle.com/javase/6/docs/api/java/lang/String.html
1 Comment
because it's a class and not a primitive data type. String is effectively an array of characters.
3 Comments
Although the compiler has special support for Strings, such as converting string literals into String instances, and performing String concatenation, String is not a primitive type, but a Class. By convention, class names begin in uppercase.
See the JLS section Types,Values and Variables for description of primitive types and reference types.
Comments
String is a non premitive data type . You can use String as follows
int monthNumber = 2;
String monthName = "";
switch(monthNumber) {
case 1:
monthName = "January";
break;
case 2:
monthName = "February";
break;
case 3:
monthName = "March";
break;
case 4:
monthName = "April";
break;
}
System.out.println("The month is " + monthName);