what is the java util scanner 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: static scanner java
import java.util.Scanner;
class ComputerScienceHomework16 {
static Scanner scanner = new Scanner(System.in);
public static void test(){
System.out.print("type a number: ");
int num = scanner.nextInt();
System.out.println("you typed the number " + num);
}
public static void main(String[] args) {
test()
}
}