java.lang.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
