In this program:
public class y {
final static byte testbuf1[] = { -16,-93,-55,-73,-19,-37 };
final static byte testbuf2[] = { 16, 93, 55, 73, 19, 37 };
public static void main(String args[]){
System.out.println("Hello");
}
}
The compiler complains on every value in testbuf1 but none of the values in testbuf2, the warning
is:
y.oak:5: Warning: Possible loss of precision. Use an explicit cast to convert int to byte.
It does *NOT* complain about the small positive integers in testbuf1.
According to the oak spec, bytes are an 8 bit signed quantity. Thus the legal range for initializers
is -127 to 128. The compiler recognizes this for the small positive integers but doesn't for the
small negative ones.
public class y {
final static byte testbuf1[] = { -16,-93,-55,-73,-19,-37 };
final static byte testbuf2[] = { 16, 93, 55, 73, 19, 37 };
public static void main(String args[]){
System.out.println("Hello");
}
}
The compiler complains on every value in testbuf1 but none of the values in testbuf2, the warning
is:
y.oak:5: Warning: Possible loss of precision. Use an explicit cast to convert int to byte.
It does *NOT* complain about the small positive integers in testbuf1.
According to the oak spec, bytes are an 8 bit signed quantity. Thus the legal range for initializers
is -127 to 128. The compiler recognizes this for the small positive integers but doesn't for the
small negative ones.