class
Test {
public static void main(
String[] args)
{
final int i=500;
short s=i;
byte b=(byte)s;
final long l=877l;
int j=(int)l;
//float f=l;
System.out.println("l=:"+l+" j=:"+j);
System.out.println("b=:"+b+" i=:"+i);
}
}
the output of the above program is
l=877
j=877
b=-12
i=500
now my question is if int daytype can be narrowed to short, why cant short be narrowed to byte automatically...as per my view i belive its becouse the value is too wide to fit in the byte range(byte range is -128 to 127) but later in the programe when long is assigned to int why it is not automatically narrowed...
can someone please explain me how b=-12..