1import java.util.Scanner;//import Scanner
2
3Scanner input=new Scanner(System.in);//Create the scanner Obj
4
5float numF = input.nextFloat();//Returns float
6int num1 = input.nextInt(); //Returns int
7byte byte1 = input.nextByte();//Returns Byte
8long lg1 = input.nextLong();//Returns long
9boolean b1 = input.nextBoolean();//Returns bool
10double num2 = input.nextDouble();//Returns Double
11String nome = input.nextLine();//Returns String
12
13//execution is pause until you give input
14
15
1If you use the nextLine() method immediately following the nextInt() method,
2nextInt() reads integer tokens; because of this, the last newline character for
3that line of integer input is still queued in the input buffer and the next
4nextLine() will be reading the remainder of the integer line (which is empty).
5So we read can read the empty space to another string might work. Check below
6code.
7import java.util.Scanner;
8
9public class Solution {
10
11 public static void main(String[] args) {
12 Scanner scan = new Scanner(System.in);
13 int i = scan.nextInt();
14
15 // Write your code here.
16 double d = scan.nextDouble();
17 String f = scan.nextLine();
18 String s = scan.nextLine();
19
20 System.out.println("String: " + s);
21 System.out.println("Double: " + d);
22 System.out.println("Int: " + i);
23 }
24}