java.util.Scanner.hasNextBigInteger()%uA0如果在此scanner 的输入的下一个标记可以使用nextBigInteger()方法被解释为一个BigInteger的默认基数,方法返回true。扫描仪不执行任何输入。
声明
以下是java.util.Scanner.hasNextBigInteger()方法的声明
public boolean hasNextBigInteger()
参数
-
NA
返回值
当且仅当此scanner%uA0的下一个标记是有效的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 System.out.println("" + scanner.hasNextBigInteger()) // 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 = true 6