java.util.Scanner.reset()%uA0方法重置该扫描仪。重设scanner 丢弃所有的这些可能已被useDelimiter(java.util.regex.Pattern)的调用改变其明确的状态信息,useLocale(java.util.Locale),或useRadix(int)。
声明
以下是java.util.Scanner.reset()方法的声明
public Scanner reset()
参数
-
NA
返回值
此方法返回此scanner
异常
-
NA
例子
下面的示例演示java.util.Scanner.reset()方法的用法。
package com.yiibai import java.util.* public class ScannerDemo { public static void main(String[] args) { String s = "Hello World! 3 + 3.0 = 6.0 true " // create a new scanner with the specified String Object Scanner scanner = new Scanner(s) // print a line of the scanner System.out.println("" + scanner.nextLine()) // change the locale of this scanner scanner.useLocale(Locale.US) // change the radix of this scanner scanner.useRadix(30) // reset and check the values for radix and locale, which are the default scanner.reset() System.out.println("" + scanner.radix()) System.out.println("" + scanner.locale()) // close the scanner scanner.close() } }
让我们来编译和运行上面的程序,这将产生以下结果:
Hello World! 3 + 3.0 = 6.0 true 10 el_GR