Is it just a char array?
+10
A:
Yes, plus some meta-data, like a start and end index (because that char array can be shared across strings, for example, when you create substrings).
Looking at the source for java.lang.String
, you see the following instance fields:
/** The value is used for character storage. */
private final char value[];
/** The offset is the first index of the storage that is used. */
private final int offset;
/** The count is the number of characters in the String. */
private final int count;
/** Cache the hash code for the string */
private int hash; // Default to 0
Thilo
2010-09-15 05:09:26
And some methods and algorithms... as `String` is an object and not a primitive `datatype`
Garis Suero
2010-09-15 05:19:00
@Garis yes, but that's not the container, that's the sugar on top
seanizer
2010-09-15 06:53:32