java - How string class difference from other classes? -
we can do:
string string = "ourstring";
but can't create objects user defined classes:
userclass uc="";
how java allowing set values directly java.lang.string class only?
java.lang.string special class.
feel free read http://docs.oracle.com/javase/7/docs/api/java/lang/string.html
it says
the string class represents character strings. string literals in java programs, such "abc", implemented instances of class.
...
the java language provides special support string concatenation operator ( + ), , conversion of other objects strings. string concatenation implemented through stringbuilder(or stringbuffer) class , append method. string conversions implemented through method tostring, defined object , inherited classes in java. additional information on string concatenation , conversion, see gosling, joy, , steele, java language specification.
no other classes have special support java language.
you should careful + feature: discussed not safe performance , memory.
Comments
Post a Comment