Java Convert Byte to BigInteger

Tags: byte BigInteger

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

How to convert byte to BigInteger in Java

In Java, with a given byte value we can use the BigInteger.valueOf(long val) static method to convert it to a BigInteger value as the example Java code below.

ConvertByteToBigIntegerExample.java

import java.math.BigInteger;

public class ConvertByteToBigIntegerExample {
    public static void main(String... args) {
        byte byteValue = 11;

        // Convert Byte to BigInteger
        BigInteger bigIntegerValue = BigInteger.valueOf(byteValue);

        System.out.println("byte value: " + byteValue);
        System.out.println("BigInteger value: " + bigIntegerValue);
    }
}
The output as below.
byte value: 11
BigInteger value: 11

Happy Coding 😊

Java Convert Byte to Hexadecimal String

Java Convert Hexadecimal String to Byte

Java Convert Byte to Octal String

Java Convert Octal String to Byte

Java Convert Byte to BigDecimal