Java Convert Byte to Hexadecimal String

Tags: byte Hexadecimal

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

How to convert byte to hexadecimal in Java

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

ConvertByteToHexExample.java

public class ConvertByteToHexExample {
    public static void main(String... args) {
        byte byteValue = 15;

        // Convert Byte to Hexadecimal String
        String hexString = Integer.toHexString(byteValue);

        System.out.println("byte value: " + byteValue);
        System.out.println("Hexadecimal  value: " + hexString);
    }
}
The output as below.
byte value: 15
Hexadecimal  value: f

Happy Coding 😊

Java Convert Hexadecimal String to Byte

Java Convert Byte to Octal String

Java Convert Octal String to Byte

Java Convert Byte to BigDecimal

Java Convert Byte to BigInteger