- 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
How to convert Decimal to Hexadecimal in Java
To convert decimal to hexadecimal, use any of the two methods i.e.
Integer.toHexString() − It returns a string representation of the integer argument as an unsigned integer in base 16.
Integer.parseInt() − It allows you to set the radix as well, for example, for hexadecimal set it as 16.
Let us see an example now to convert decimal to hexadecimal using Integer.toHexString() method.
Example
public class Demo { public static void main( String args[] ) { int dec = 158; System.out.println(Integer.toHexString(dec)); } }
Output
9e
Let us see an example now to convert decimal to hexadecimal using Integer.parseInt() method.
Example
public class Demo { public static void main( String args[] ) { String str = "3d8"; System.out.println(Integer.parseInt(str, 16)); } }
Output
984
- Related Articles
- How to Convert Decimal to Hexadecimal?
- How to Convert Hexadecimal to Decimal?
- Convert decimal integer to hexadecimal number in Java
- Java Program to convert from decimal to hexadecimal
- Java program to convert decimal number to hexadecimal number
- Java Program to convert hexadecimal number to decimal number
- Java Program to convert decimal integer to hexadecimal number
- Haskell Program to convert Decimal to Hexadecimal
- Swift Program to convert Hexadecimal to Decimal
- Swift Program to convert Decimal to Hexadecimal
- Golang Program to convert Decimal to Hexadecimal
- Golang Program to convert Hexadecimal to Decimal
- Haskell Program to convert Hexadecimal to Decimal
- How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
- Convert Hexadecimal to Octal in Java?

Advertisements