Java Convert Integer to Hexadecimal String
Tags: Integer Hexadecimal
In this Java core tutorial we learn how to convert an Integer value into a hexadecimal String in Java programming language.
How to convert Integer to Hex String in Java
In Java, with a given Integer value we can use the Integer.toHexString(int i) static method to convert it to a hexadecimal String as the example Java code below.
ConvertIntegerToHexExample.java
public class ConvertIntegerToHexExample {
public static void main(String... args) {
int intValue = 1024;
// Convert Integer to Hexadecimal String
String hexString = Integer.toHexString(intValue);
System.out.println("int value: " + intValue);
System.out.println("hexadecimal value: " + hexString);
}
}
int value: 1024
hexadecimal value: 400
Happy Coding 😊
Related Articles
Java Convert Hexadecimal String to short