Java - Write code to convert int to to Hex String

Requirements

Write code to convert int to Hex String

Add # in front of it

Hint

Use Integer.toHexString()

Demo

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