java.lang.Integer.toHexString()方法

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));
   }  
}

让我们来编译和运行上面的程序,这将产生以下结果:

扫描二维码关注公众号,回复: 2644971 查看本文章
Number = 170
Hex = aa

猜你喜欢

转载自blog.csdn.net/weixin_38266599/article/details/81332904