Write code to convert int to Hex String
Add # in front of it
Use Integer.toHexString()
//package com.book2s; public class Main { public static void main(String[] argv) { int c = 42; System.out.println(toHexString(c)); }/*ww w . ja va 2s .co m*/ public static String toHexString(int c) { return "#" + Integer.toHexString(c); } }