Beginners Programs :

Java Program Convert Decimal To Hexadecimal | Vice Versa

Java Program to convert Decimal to Hexadecimal vice versa Hexadecimal to Decimal. Here we have written the code in three different ways using arrays, static method, recursion, vice versa with sample output and an example program. Before getting into the programming a couple of lines just to let you know the basics.

  • What is Decimal?

A decimal number system is a term with base 10. It’s most commonly used number system.  The decimal number system consists of 10 digits from 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

  • What is Hexadecimal?

Same as like: but with a different numbering system:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

  • How to convert then?

Conversion is quite simple: Just look at the Image here:

  • Example: Convert the number 256 from decimal to hexadecimal
[table id=13 /]
  • Example – 2: Convert 188:

[table id=15 /]

1. Using Array

[wp_ad_camp_3]

Output:

 

2. Static Method

Another example program with sample output: #Static Method.

Output:

3. Using Recursion

  • Another example program using recursion: A function call itself.

Output:

4. Vice versa: convert hexadecimal to Decimal

Here is the Java code program conversion from Hexadecimal to decimal with sample outputs:

Output:

List of other programs: