There's no such thing as "the empty string character". A character is always a UTF-16 code unit, and there's no "empty" code unit. There's "an empty string" which is represented exactly the same way as any other string:
- A
char[]
reference - An index into that
char[]
- A length
In this case, the length would be 0. The char[]
reference could potentially be a reference to an empty char array, which could potentially be shared between all instance of String
which have a length of 0.
(Code such as substring
could be implemented by detecting 0-length requests and always returning the same reference to an empty string, but I'm not aware of implementations doing that.)