Java Integer to Hex intToHex(int num)

Here you can find the source of intToHex(int num)

Description

Int to hex.

License

Open Source License

Parameter

Parameter Description
num the num

Return

the string

Declaration

public static String intToHex(int num) 

Method Source Code

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

Related

  1. intToHex(int i)
  2. intToHex(int i)
  3. intToHex(int i)
  4. IntToHex(int i, int length)
  5. intToHex(int id)
  6. intToHex(int val)
  7. intToHex(int val, char delim)
  8. intToHex(int val, StringBuffer sb)
  9. intTohex2(int value)