0 votes
1.3k views
in Java by
How to convert decimal to hexadecimal in java?

1 Answer

0 votes
by

package com.convert;

public class ConvertDecimalToHexaDecimal {

    /**
     * @param args
     */
    public static void main(String[] args) {
        int decimalNum = 17;
        String hexaDedecimal = getDecimalToHexaDecimal(decimalNum);
        System.out.println("Decimal : " + decimalNum);
        System.out.println("HexaDecimal : " + hexaDedecimal);
    }

    private static String getDecimalToHexaDecimal(int decimalNum) {
        String hexaDedecimal = Integer.toHexString(decimalNum);
        return hexaDedecimal;
    }

}
 

Output:

Decimal : 17
HexaDecimal : 11

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...