Java tutorial
//package com.java2s; import java.util.HashMap; public class Main { static HashMap intToString = new HashMap(); public static String getStringForColor(int c) { String result = (String) intToString.get(new Integer(c)); if (result != null) { return result; } return getHexForColor(c); } public static String getHexForColor(int c) { return "#" + Integer.toHexString((c & 0xffffff) | 0x1000000).substring(1); } }