7/17/15

Difference between Char array and byte array




In some languages char datatype is of 1 byte. So in those cases char is directly equivalent to byte.
And you can confidently say that your char array and byte array are same thing.

In java there is difference between char array and byte array. More precisely there is difference between char and byte.

Reason


To adopt wide range of symbols java use Unicode encoding that is of sixteen bits or 2 bytes. So in Java 2 bytes are needed to form a character. It is quite clear by now that char and bytes are not same thing in Java.

So char array is different than bytes array in Java.