I was trying to understand character encoding in Java. Characters in Java are being stored in 16 bits using UTF-16 encoding. So while i am converting a string containing 6 c
As per the String.getBytes() method's documentation, the string is encoded into a sequence of bytes using the platform's default charset.
I assume, your platform default charset will be ISO-8859-1 (or a similar one-byte-per-char-charset). These charsets will encode one character into one byte.
If you want to specify the encoding, use the method String.getBytes(Charset) or String.getBytes(String).
About the 16-bit storing: This is how Java internally stores characters, so also strings. It is based on the original Unicode specification.