int val = 233;
byte b = (byte) val;
System.out.println(b);
I have a simple case: I have one integer with some value & I want to convert that value into a byte for output. But in this case, a negative value is coming.
How can I successfully place the int value to byte type?
In Java byte range is -128 to 127. You cannot possibly store the integer 233 in a byte without overflowing.