首页javaintegerJava Data Type - 如何声明十六进制整数文本

Java Data Type - 如何声明十六进制整数文本

我们想知道如何声明十六进制整数文本。

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); } }