Java 语言 `Integer.toHexString()` 方法及其示例
`java.lang.Integer.toHexString()` 方法以 16 进制中的无符号整数的对数形式返回整型参数的字符串表示。
我们现在看一个示例 −
示例
import java.lang.*;
public class Main {
public static void main(String[] args) {
int i = 160;
System.out.println("Number = " + i);
System.out.println("Hex = " + Integer.toHexString(i));
}
}输出
Number = 160 Hex = a0
示例
现在我们看一个负数的另一个示例 −
import java.lang.*;
public class Main {
public static void main(String[] args) {
int i = -160;
System.out.println("Number = " + i);
System.out.println("Hex = " + Integer.toHexString(i));
}
}输出
Number = -160 Hex = ffffff60
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言
C++
C#
MongoDB
MySQL
Javascript
PHP