Counting from 0 through 15 in hex looks like this:
0 1 2 3 4 5 6 7 8 9 a b c d e f
Java will accept capital or lowercase letters for the extra digits.
0XCAFE and 0xcafe are both legal and have the same value.
public class MainClass{
public static void main(String[] argv){
int intValue = 0x1c; //hex digits may be upper- or lowercase
int intValue2 = 0x1C;
int intValue3 = 0X1c;
int intValue4 = 0X1C;
int x = 0X0001;
int y = 0x7fffffff;
int z = 0xDead;
System.out.println("x = " + x + " y = " + y + " z = " + z);
}
}
|