java scanner program code example
Example 1: java scanner
import java.util.Scanner;
// import scanner
Scanner myScanner = new Scanner(System.in); // Make scanner obj
String inputString = myScanner.nextLine(); // Take whole line
boolean inputBoolean = myScanner.nextBoolean(); //Boolean input
long inputLong = myScanner.nextLong(); //Interger,long ... input
Example 2: how to take input in java
Scanner sc = new Scanner(System.in); // Create a Scanner object
String userName = sc.nextLine();//read input string
int age = sc.nextInt(); //read input integer
long mobileNo = sc.nextLong(); //read input long
double cgpa = sc.nextDouble(); //read input double
System.out.println(userName);//output