- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to convert decimal number to hexadecimal number
The java.lang.Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
The toHexString() method of the Integer class returns a string representation of the integer argument as an unsigned integer in base 16 (hexadecimal).
Example
import java.util.Scanner; public class DecimalTohexadecimal { public static void main(String args[]){ Scanner sc = new Scanner(System.in); System.out.println("Enter a decimal number ::"); int decimal = sc.nextInt(); String result = Integer.toHexString(decimal); System.out.println("Hexa deciimal value of the given decimal number is ::"+result); } }
Output
Enter a decimal number:: 554 Hexadecimal value of the given decimal number is ::22a
- Related Articles
- Java Program to convert hexadecimal number to decimal number
- Java Program to convert decimal integer to hexadecimal number
- Convert decimal integer to hexadecimal number in Java
- Java Program to convert from decimal to hexadecimal
- Java Program to convert binary number to decimal number
- Java Program to convert octal number to decimal number
- Golang Program to convert Decimal to Hexadecimal
- Golang Program to convert Hexadecimal to Decimal
- Swift Program to convert Hexadecimal to Decimal
- Swift Program to convert Decimal to Hexadecimal
- Haskell Program to convert Decimal to Hexadecimal
- Java program to convert decimal number to binary value
- Java program to convert decimal number to octal value
- Java program to convert binary number to decimal value
- Java program to convert float decimal to Octal number

Advertisements