Java Data Type Tutorial - Java BigInteger(byte[] val) Constructor








Syntax

BigInteger(byte[] val) constructor from BigInteger has the following syntax.

public BigInteger(byte[] val)

Example

In the following code shows how to use BigInteger.BigInteger(byte[] val) constructor.

//from   ww w.j  a v a  2  s .com
import java.math.BigInteger;

public class Main {
  public static void main(String[] argv) throws Exception {
    // A negative value
    byte[] bytes = new byte[] { (byte) 0xFF, 0x00, 0x00 }; // -65536
    // A positive value
    bytes = new byte[] { 0x1, 0x00, 0x00 }; // 65536
    BigInteger bi = new BigInteger(bytes);
  }
}