scanner in java

Java
//Import Scanner in java
import java.util.Scanner;

class classname{
  public methodname(){
    //Scanner declaration
    Scanner s_name = new Scanner(System.in);
    //Use Scanner to take input
    int val = s_name.nextInt();
  }
}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 ... inputimport java.util.Scanner;import java.util.scanner;

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

// Examples:
Scanner user = new Scanner(system.in);
Scanner text = new Scanner(new File("text.txt"));import java.util.Scanner;
...
  Scanner console = new Scanner(System.in);
  int num = console.nextInt();
  console.nextLine() // to take in the enter after the nextInt() 
  String str = console.nextLine();
Source

Also in Java: