Wrapper classes are used to “wrap” the primitives data types into objects so that they can be included in the activities which are reseved for the objects. String class wraps the string literals to an object.
In this scenario can we call String as a wrapper class ?
According to wikipedia, a (primitive) wrapper class in Java is one of those eight classes that wrap a (=one) primitive value.
Stringwraps achar[]so according to this it is not a (primitive) wrapper class.Furthermore,
Stringis not designed to wrap or decorate a character array.Stringhas been designed to model a string, a character sequence and the current implementation uses an internalchar[]. But Sun could also have chosen to use abyte[]a long with a character encoding hint, a collection or something native. That doesn’t matter.That’s different for the primitive wrappers: they have been designed only to wrap a primitive, to adapt a java primitive to
java.lang.Object.