The program must start with this import java.util.*; Again it must be before the class name but inside the method code.
What is the difference of the Scanner to BufferedReader
Scanner uses less code than the BufferedReader.
Code:
- Code:
-
import java.util.*;
Scanner scName = new Scanner(System.in);
Sample Program:
- Code:
-
import java.util.*;
class progName{
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
String stringVar = scnr.nextLine();
int intVar = scnr.nextInt();
Double doubleVar = scnr.nextDouble();
Float floatVar = scnr.nextFloat();
}
}