Android Hex String Create makeHex(int val)

Here you can find the source of makeHex(int val)

Description

make Hex

Declaration

public static String makeHex(int val) 

Method Source Code

//package com.java2s;

public class Main {
    public static String makeHex(int val) {
        String ret = "";
        String[] hexChars = new String[16];
        for (int i = 0; i < 10; i++) {
            hexChars[i] = String.valueOf(i);
        }//from ww w.ja  va  2  s .  com
        hexChars[10] = "A";
        hexChars[11] = "B";
        hexChars[12] = "C";
        hexChars[13] = "D";
        hexChars[14] = "E";
        hexChars[15] = "F";
        int main, remain;
        while (val > 0) {
            main = val / 16;
            remain = val % 16;
            ret = hexChars[remain] + ret;
            val = main;
        }
        return ret;
    }
}

Related

  1. appendHex(final StringBuffer buf, final int i)
  2. toHex(final int i)
  3. appendHexJavaScriptRepresentation(int codePoint, Appendable out)
  4. appendHexJavaScriptRepresentation(StringBuilder sb, char c)
  5. bytesToHexString(byte[] bArray)
  6. makeInt(String hex)
  7. appendHexJavaScriptRepresentation(int codePoint, Appendable out)
  8. appendHexJavaScriptRepresentation(StringBuilder sb, char c)
  9. hexToBytes(CharSequence str)