Javatpoint Logo
Javatpoint Logo

Java Scanner nextBigInteger() Method

The nextBigInteger() of Java Scanner class method is used to scan the next token of the input as a BigInteger. There is two different types of Java nextBigInteger() method which can be differentiated depending on its parameter. These are:

  • Java Scanner nextBigInteger() Method
  • Java Scanner nextBigInteger(int radix) Method

nextBigInteger() Method

This is a Java Scanner class method which is used to scan the next token of the input as a BigInteger in the default radix.

nextBigInteger(int radix) Method

This is an inbuilt method of Java Scanner class which is used to scan the next token of the input as a BigInteger in the specified radix.


Following is the declaration of nextBigInteger() method:


DataType Parameter Description Required/Optional
int radix It is used to interpret the token as a BigInteger value. Required


The nextBigInteger() method returns the BigInteger value scanned from the input.


IllegalStateException- This method throws exception if the innvocation is done after the scanner has been closed.

IllegalArgumentException- It throws this exception if the specified radix is out of range.

InputMismatchException- It throws this exception if the next token does not match the Integer regular expression, or is out of range.

Compatibility Version

Java 1.5 and above

Example 1


Enter BigInteger Number to check prime: 37427347

Example 2


Enter Value of a: 123456
Enter Value of b: 123456
Result: 15241383936

Example 3


Found: 55454
Not Found: JavaTpoint
Found: 1
Not Found: +
Found: 1
Not Found: =
Not Found: 2.0
Not Found: False
Not Found: -7987AB

Example 4


Output: 85

Example 5


Not Found : Java
Exception in thread "main" java.lang.IllegalArgumentException: radix:81
	at java.base/java.util.Scanner.setRadix(
	at java.base/java.util.Scanner.nextBigInteger(
	at myPackage.ScannerNextBigIntegerExample5.main(
Next TopicJava Scanner Class

Help Others, Please Share

facebook twitter pinterest