scanner method java code example
Example 1: java scanner
import java.util.Scanner;
Scanner myScanner = new Scanner(System.in);
String inputString = myScanner.nextLine();
boolean inputBoolean = myScanner.nextBoolean();
long inputLong = myScanner.nextLong();
Example 2: how to use scanners in java
import java.util.Scanner;
Public class Scanner {
Public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Type anything and the scanner will take that input and print it");
String next = scan.next();
System.out.println(next);
}
}
Example 3: java scanner
import java.util.Scanner;
Scanner input=new Scanner(System.in);
float numF = input.nextFloat();
int num1 = input.nextInt();
byte byte1 = input.nextByte();
long lg1 = input.nextLong();
boolean b1 = input.nextBoolean();
double num2 = input.nextDouble();
String nome = input.nextLine();
Example 4: scanner java
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();