Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Hexadecimal integer literal

Put 0x or 0X in front of the numbers. Use the letters A to F (or a to f) to represent digits with values 10 to 15, respectively. public class MainClass {   public static void main(String[] a) {     int hexValue1 = 0x100;     int hexValue2 = 0x1234;     int hexValue3 = 0xDEAF;     int hexValue4 = 0xCAB;     System.out.println(hexValue1);     System.out.println(hexValue2);     System.out.println(hexValue3);     System.out.println(hexValue4);   } } 256 4660 57007 3243