please write the program of this using scanner in java.
Share
please write the program of this using scanner in java.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
import java.util.*;
public class ScannerClassExample2 {
public static void main(String args[]){
String str = "Hello/This is JavaTpoint/My name is Abhishek.";
//Create scanner with the specified String Object.
Scanner scanner = new Scanner(str);
System.out.println("Boolean Result: "+scanner.hasNextBoolean());
Answer:
If you want scanner, you first need to import it:
import java.util.Scanner;
Scanner as = new Scanner(System.in);
int x = as.nextInt;