前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到教程。
用例: Long.toHexString(number) 其中 number 是一个long类型参数。
描述:
java.lang.Integer.toHexString() 方法返回为无符号整数基数为16的整数参数的字符串表示形式。以下字符作为十六进制数字:0123456789ABCDEF。
声明:
以下是java.lang.Integer.toHexString()方法的声明
public static String toHexString(int i)
static String toHexString(int i)
参数
-
i -- 这是一个整数被转换为一个字符串.
返回值 :
此方法返回的字符串表示的无符号整数参数所表示的值以十六进制(基数为16).
实例:
下面的例子显示使用的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 valuerepresented by the argument in hexadecimal (base 16) */System.out.println("Hex = " + Integer.toHexString(i));}
}
让我们来编译和运行上面的程序,这将产生以下结果:
Number = 170
Hex = aa