Java Program for Decimal to Hex converter

Converting Decimal number Hexadecimal Conversion using Java Code


In Integer wrapper class we have an default method called toHexString by using that method we can convert the Decimal number to Hex Number as String easily. Below example will help you to convert the Decimal number to Hex format. When you run this code the program will ask the Decimal input once you enter the decimal value it will display the converted result in Hex format.
//source code DecimalHex.java

import java.util.*;

public class DecimalHex {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a Decimal Number");
int i = in.nextInt();
String strHexNumber = Integer.toHexString(i);
System.out.println("Convert decimal number to hexadecimal number example");
System.out.println("Hexadecimal value of " + i + " is " + strHexNumber);
}
}


You can also convert using online Decimal to Hex Converter


Related Topic Decimal to Binary Number Converter in Java Program
Binary Subtraction in Java
Decimal to Binary Number Converter in C Program
Biggest Hurdle of XML Schema
How to Set Java Heap size
Java  

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback