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

Code Example 1

import java.util.scanner;

Scanner *scanner name* = new Scanner(*input source*);

// Examples:
Scanner user = new Scanner(;
Scanner text = new Scanner(new File("text.txt"));

Code Example 2

import java.util.Scanner;

Code Example 3

import java.util.Scanner;

Public class Scanner {
	Public static void main(String[] args) {
    	// Scanner *scanner name here* = new Scanner(;
      	Scanner scan = new Scanner(;
      	System.out.println("Type anything and the scanner will take that input and print it");
      	String next =;

Learn ReactJs, React Native from