taking inputs in java using scanner code example
Example 1: 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 2: how to input in java
import java.util.Scanner;
...
Scanner console = new Scanner(System.in);
int num = console.nextInt();
console.nextLine()
String str = console.nextLine();