java.util.Scanner.hasNextBigInteger(int radix)%uA0如果在此scanner 的输入的下一个标记可以使用nextBigInteger()方法被解释为一个BigInteger指定基数方法返回true。scanner 不执行任何输入。
声明
以下是java.util.Scanner.hasNextBigInteger()方法的声明
public boolean hasNextBigInteger(int radix)
参数
-
radix%uA0-- 用于将标记解释为一个整数的基数
返回值
当且仅当此scanner 的下一个标记是有效的BigInteger此方法返回true
异常
-
IllegalStateException%uA0-- 如果此scanner已关闭
例子
下面的示例演示java.util.Scanner.hasNextBigInteger()方法的用法。
package com.yiibai import java.util.* public class ScannerDemo { public static void main(String[] args) { String s = "Hello World! 3 + 3.0 = 6" // create a new scanner with the specified String Object Scanner scanner = new Scanner(s) while (scanner.hasNext()) { // check if the scanner&aposs next token is a BigInteger with radix 5 System.out.println("" + scanner.hasNextBigInteger(4)) // print what is scanned System.out.println("" + scanner.next()) } // close the scanner scanner.close() } }
让我们来编译和运行上面的程序,这将产生以下结果:
false Hello false World! true 3 false + false 3.0 false = false 6