static String toHexString(int i)
描述 (Description)
java.lang.Integer.toHexString()方法返回整数参数的字符串表示形式,作为基数为16的无符号整数。以下字符用作十六进制数字: 0123456789abcdef 。
声明 (Declaration)
以下是java.lang.Integer.toHexString()方法的声明
public static String toHexString(int i)
参数 (Parameters)
i - 这是一个要转换为字符串的整数。
返回值 (Return Value)
此方法返回由十六进制(基数16)中的参数表示的无符号整数值的字符串表示形式。
异常 (Exception)
NA
例子 (Example)
以下示例显示了java.lang.Integer.toHexString()方法的用法。
package com.iowiki;
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