Here you can find the source of intToHex(int num)
Parameter | Description |
---|---|
num | the num |
public static String intToHex(int num)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from ww w .j a v a 2s. c om*/ * Int to hex. * * @param num the num * * @return the string */ public static String intToHex(int num) { char[] chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; int i1 = num / 16; int i2 = num % 16; StringBuffer ret = new StringBuffer(); ret.append(chars[i1]); ret.append(chars[i2]); return ret.toString(); } }