java.lang.Integer.toHexString()方法用法实例教程 - 此方法返回的字符串表示的无符号整数参数所表示的值以十六进制(基数为16)
描述:
Thjava.lang.Integer.toHexString() 方法返回为无符号整数基数为16的整数参数的字符串表示形式。以下字符作为十六进制数字:0123456789ABCDEF。
声明
以下是java.lang.Integer.toHexString()方法的声明
public static String toHexString(int i)
参数
-
i -- 这是一个整数被转换为一个字符串.
返回值
此方法返回的字符串表示的无符号整数参数所表示的值以十六进制(基数为16).
异常
-
NA
实例
下面的例子显示使用的java.lang.Integer.toHexString()方法.
package com.yiibai;
import java.lang.*;
public class IntegerDemo {
public static void main(String[] args) {
int i = 170;
System.out.println("Number = " + i);
/* returns the string representation of the unsigned integer value
represented by the argument in hexadecimal (base 16) */
System.out.println("Hex = " + Integer.toHexString(i));
}
}
让我们来编译和运行上面的程序,这将产生以下结果:
Number = 170 Hex = aa
本文介绍 Java 中 Integer 类的 toHexString 方法使用方法,该方法用于将整数转换为十六进制字符串表示形式。文章通过示例代码展示了如何进行转换。

2791

被折叠的 条评论
为什么被折叠?



