Hexadecimal integer literal (To indicate hexadecimal, prefix the literal with 0x or 0X) : Integer « Java Source And Data Type « SCJP






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);
   
  }
}
x = 1 y = 2147483647 z = 57005








1.9.Integer
1.9.1.Ranges of the Integral Primitive Types
1.9.2.An integer literal is a value specified in the program source.
1.9.3.The default value for an integer primitive is zero.
1.9.4.Default Integral literal is decimal
1.9.5.Octal integer literal (To indicate octal, prefix the literal with 0 (zero))
1.9.6.Hexadecimal integer literal (To indicate hexadecimal, prefix the literal with 0x or 0X)
1.9.7.octal, decimal, and hexadecimal may be specified as long by placing a suffix of L or l after the number
1.9.8.out of range for short primitive
1.9.9.Assign a primitive variable using a literal or the result of an expression.
1.9.10.A literal integer is always an int, compiler automatically narrows the literal value to a byte
1.9.11.Add two bytes together and you'll get an int.
1.9.12.Integer literals are assumed to be of type int unless the letter L or l is appended.
1.9.13.Division by zero in integer arithmetic produces a runtime ArithmeticException.