Java中十六进制转换 Integer.toHexString()
生活随笔
收集整理的這篇文章主要介紹了
Java中十六进制转换 Integer.toHexString()
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
前些天發現了一個巨牛的人工智能學習網站,通俗易懂,風趣幽默,忍不住分享一下給大家。點擊跳轉到教程。
用例: 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?
?
?
總結
以上是生活随笔為你收集整理的Java中十六进制转换 Integer.toHexString()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Spring中的计时器StopWatch
- 下一篇: Java实现Excel导入数据库,数据库