I get a char array from a socket :
char[] cbuf = new char[3];
inputStream.read(cbuf, 0, 3); // read 3 chars in buffer "cbuf", offset = 0
Then when I print that :
System.out.println("r:"+(int)cbuf[0]+" g:"+(int)cbuf[1]+" b:"+(int)cbuf[2]);
I get at some point :
...
r:82 g:232 b:250
r:82 g:232 b:250
r:66 g:233 b:8224
The 8224 value is way more than 255, how can a char contain this value ???
Thank you
The
charprimitive in Java in 16 bits wide, to accommodate characters outside the standard ASCII range, using Unicode.It looks like you’re trying to store RGB values in a
char[3]. May I suggest abyte[3], or java.awt.Color?