tags:

views:

141

answers:

1

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
And some methods and algorithms... as `String` is an object and not a primitive `datatype`
Garis Suero
@Garis yes, but that's not the container, that's the sugar on top
seanizer