Check out example codes for "how to use scanner class in java". It will help you in understanding the concepts better.

Code Example 1

import java.util.Scanner;

// import scanner 

Scanner myScanner = new Scanner(; // Make scanner obj

String inputString = myScanner.nextLine(); // Take whole line

boolean inputBoolean = myScanner.nextBoolean(); //Boolean input

long inputLong = myScanner.nextLong(); //Interger,long ... input

Code Example 2

import java.util.Scanner;

Code Example 3

// import Scanner
import java.util.Scanner;

// Initialize Scanner
Scanner input = new Scanner(;

// Test program with Scanner
System.out.println("What is your name?");
String name = input.nextLine();

System.out.println("Hello," + name + " , it is nice to meet you!");

Learn ReactJs, React Native from