public class Test8{
public static void main(
String a[]){
byte b = 1;
char c = 2;
short s = 3;
int i = 4;
c = b; // 1
s = b; // 2
i = b; //3
}
}
The above code will not compile since at marker //1 it is trying to move a byte to char.
1. Not sure why it is not letting it even though byte is only 8 bits and char can hold upto 16 bits..
2. On the other hand if the byte declaration is changed to final byte =1 the code compiles...
Can anyone explain this..
Thanks
JP