Java 中十六进制整数字面量
对于十六进制,需要将 0x 或 0X 放在数字的开头。
注意 − 数字 10 到 15 在十六进制中由 a 到 f(A 到 F)表示
以下是一些声明并初始化为 int 类型的十六进制整数字面量的示例。
int one = 0X123; int two = 0xABC;
示例
public class Demo {
public static void main(String []args) {
int one = 0X123;
int two = 0xABC;
System.out.println("Hexadecimal: "+one);
System.out.println("Hexadecimal: "+two);
}
}
输出
Hexadecimal: 291 Hexadecimal: 2748
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP