CoreJava Variable
CoreJava Variable
Example-
byte b = 10; // 10 is of byte type
int i = b; // assign byte to int
System.out.println(i); // now 10 is of int type
i+=240;
System.out.println(i); // 250 ie more than byte range..
B) Data Loss
int i = 128;
Convert int to byte
byte b = (byte) i; // downcast but 128 is out of Range
System.out.println(b); // -127 as it is out of range it starts from
negative i.e data loss.