- 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 lang Integer.toHexString() Method with Examples
The java.lang.Integer.toHexString() method returns a string representation of the integer argument as an unsigned integer in base 16.
Let us now see an example −
Example
import java.lang.*; public class Main { public static void main(String[] args) { int i = 160; System.out.println("Number = " + i); System.out.println("Hex = " + Integer.toHexString(i)); } }
Output
Number = 160 Hex = a0
Example
Let us now see another example for negative number −
import java.lang.*; public class Main { public static void main(String[] args) { int i = -160; System.out.println("Number = " + i); System.out.println("Hex = " + Integer.toHexString(i)); } }
Output
Number = -160 Hex = ffffff60
Advertisements