Java Scanner nextBigInteger() MethodThe 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:
nextBigInteger() MethodThis 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) MethodThis 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. SyntaxFollowing is the declaration of nextBigInteger() method: Parameter
ReturnsThe nextBigInteger() method returns the BigInteger value scanned from the input. ExceptionsIllegalStateException- 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 VersionJava 1.5 and above Example 1Output: Enter BigInteger Number to check prime: 37427347 prime Example 2Output: Enter Value of a: 123456 Enter Value of b: 123456 Result: 15241383936 Example 3Output: Found: 55454 Not Found: JavaTpoint Found: 1 Not Found: + Found: 1 Not Found: = Not Found: 2.0 Not Found: False Not Found: -7987AB Example 4Output: Output: 85 Example 5Output: Not Found : Java Exception in thread "main" java.lang.IllegalArgumentException: radix:81 at java.base/java.util.Scanner.setRadix(Scanner.java:1368) at java.base/java.util.Scanner.nextBigInteger(Scanner.java:2673) at myPackage.ScannerNextBigIntegerExample5.main(ScannerNextBigIntegerExample5.java:11)
Next TopicJava Scanner Class
|