
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How to Convert Decimal to Hexadecimal?
- How to Convert Hexadecimal to Decimal?
- Java Program to convert from decimal to hexadecimal
- Convert decimal integer to hexadecimal number in Java
- How to convert decimal to hexadecimal in JavaScript?
- 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
- How to Convert Decimal to Binary, Octal, and Hexadecimal using Python?
- Java Program to convert integer to hexadecimal
- How to Convert Binary to Hexadecimal?
- C++ program for hexadecimal to decimal
- Convert Decimal to Binary in Java
- Convert a byte to hexadecimal equivalent in Java
- Program for decimal to hexadecimal conversion in C++
Advertisements