In Java, we can directly use String
to declare a string variable name and specify its value. We do not have to define the string as an array by using new keywor
String is non-primitive because only class can have methods. Primitive can not. And String need many functions to be called upon while processing like substring, indexof, equals, touppercase. It would not have been possible without making it class.
Also class has made it possible to make strings immutable and final to enhance security and efficiency by allowing pooling.