1Scanner sc = new Scanner(System.in); // Create a Scanner object
2String userName = sc.nextLine();//read input string
3int age = sc.nextInt(); //read input integer
4long mobileNo = sc.nextLong(); //read input long
5double cgpa = sc.nextDouble(); //read input double
6System.out.println(userName);//output
1Scanner sc = new Scanner(System.in);
2String s = sc.next();
3int n = sc.nextInt();
4double d = sc.nextDouble();
5float f = sc.nextFloat();
6
7// more fast way
8BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9String s = br.readLine(); // read line
10int c = br.read(); // read single char
13 ways to read input from console in java
2-----------------------------
3
41. Using BufferedReader Class
52. Using Scanner Class
63. Using Console Class
7
8//bufferedreader class
9
10import java.io.BufferedReader;
11import java.io.IOException;
12import java.io.InputStreamReader;
13...
14public static void main(String[] args) throws IOException
15...
16BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
17String name = reader.readLine();
18
19//Scanner class
20
21import java.util.Scanner;
22...
23
24String name = new Scanner(System.in);
25
26//Console class:
27
28String name = Syste.console().readLine();