Java convert short to BigInteger

Tags: short BigInteger

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

How to convert short to BigInteger in Java

In Java, we can use the BigInteger.valueOf(long val) static method to instantiate a new BigInteger object from a given byte value as the following Java program.

ConvertShortToBigIntegerExample1.java

import java.math.BigInteger;

public class ConvertShortToBigIntegerExample1 {
    public static void main(String... args) {
        short shortValue = 987;

        BigInteger bigInteger = BigInteger.valueOf(shortValue);

        System.out.println("short value: " + shortValue);
        System.out.println("BigInteger value: " + bigInteger);
    }
}
The output as below.
short value: 987
BigInteger value: 987

Happy Coding 😊

Java convert short to long

Java convert short to byte

Java convert short to BigDecimal

Java convert short to char

Java convert long to short

Java convert char to short

Java convert byte to short