java里面有radix树吗_boolean hasNextInt(int radix)

boolean hasNextInt(int radix)

描述 (Description)

如果此扫描器输入中的下一个标记可以使用nextInt()方法解释为指定基数中的int值,则java.util.Scanner.hasNextInt(int radix)方法返回true。 扫描仪不会超过任何输入。

声明 (Declaration)

以下是java.util.Scanner.hasNextInt()方法的声明public boolean hasNextInt(int radix)

参数 (Parameters)

radix - 用于将标记解释为int值的基数

返回值 (Return Value)

当且仅当此扫描器的下一个标记是有效的int值时,此方法才返回true

异常 (Exception)

IllegalStateException - 如果此扫描程序已关闭

例子 (Example)

以下示例显示了java.util.Scanner.hasNextInt()方法的用法。package com.iowiki;

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's next token is an int with a radix of 4

System.out.println("" + scanner.hasNextInt(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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值