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
1import java.util.*;
2class a
3{
4 void main ()
5 {
6 Scanner in = new Scanner(System.in);
7 System.out.print("Please enter you age: ");
8 int age = in.nextInt();
9 System.out.print("Please enter today's date: ");
10 int date = in.nextInt();
11 System.out.print("Please enter current month: ");
12 int month = in.nextInt();
13 System.out.print("Please enter current year: ");
14 int year = in.nextInt();
15 }
16}
17// ENJOY!!!!!!!
1import java.util.Scanner;
2...
3 Scanner console = new Scanner(System.in);
4 int num = console.nextInt();
5 console.nextLine() // to take in the enter after the nextInt()
6 String str = console.nextLine();
1//For continues reading a line
2import java.util.Scanner;
3
4Scanner in = new Scanner(System.in);
5while(in.hasNextLine()) {
6 String line = in.nextLine();
7 System.out.println("Next line is is: " + line);
8}