close(): This method is available in java.util.Scanner class of Java.
Syntax:
void java.util.Scanner.close()
This method closes this scanner.
Parameters: NA
Returns: NA
Exceptions: NA
Approach
Java
import java.util.Scanner;public class Scannerclose {public static void main(String[] args) {String source = "Hello World";Scanner scanner = new Scanner(source);System.out.println(scanner.nextLine());scanner.close();}}
Output:
Hello World
No comments:
Post a Comment