Java Convert short to Hexadecimal String

Tags: short Hexadecimal

In this Java core tutorial we learn how to convert a short value to a hexadecimal String in Java programming language.

How to convert short to hexadecimal String in Java

In Java, with a given short value we can use the Integer.toHexString(int i) static method to convert it to String in hexadecimal base 16 as the following Java program.

ConvertShortToHexExample1.java

public class ConvertShortToHexExample1 {
    public static void main(String... args) {
        short shortValue = 512;
				
				// Convert short to Hexadecimal String
        String hexString = Integer.toHexString(shortValue);

        System.out.println("short value: " + shortValue);
        System.out.println("hexadecimal value: " + hexString);
    }
}
The output as below.
short value: 512
hexadecimal value: 200

Happy Coding 😊

Java Convert Hexadecimal String to short

Java Convert Hexadecimal String to Integer

Java Convert Integer to Hexadecimal String