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));
    }/*from  w  w w.  j a  va2 s  .c o  m*/

    public static String toHexString(int c) {
        return "#" + Integer.toHexString(c);
    }
}