Returns number in 0xABCDEF-Format - Java java.lang

Java examples for java.lang:int Format

Description

Returns number in 0xABCDEF-Format

Demo Code


//package com.java2s;

public class Main {
    /**//from   w w w.  j  a  v a2s .  c om
     * Returns number in 0xABCDEF-Format
     *
     * @param n
     * @return
     */
    public static String printHexNumber(int n) {
        return "0x" + Integer.toHexString(n).toUpperCase();
    }
}

Related Tutorials