Java.util.Scanner.remove() 方法
描述
java.util.Scanner.remove() 方法不支持迭代器的此实现。
声明
以下是 java.util.Scanner.remove() 方法的声明
public void remove()
参数
NA
返回值
此方法不返回值。
异常
UnsupportedOperationException − 如果这个方法被调用。
示例
下面的例子展示了 java.util.Scanner.remove() 方法的使用。
package com.tutorialspoint;
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());
// attempt to call remove results in an exception
scanner.remove();
// close the scanner
scanner.close();
}
}
让我们编译并运行上面的程序,这将产生以下结果 −
Hello World! 3 + 3.0 = 6.0 true Exception in thread "main" java.lang.UnsupportedOperationException

