-2
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d = scan.nextDouble();
        String s = scan.nextLine();

        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }

}
Iłya Bursov
  • 20,672
  • 4
  • 30
  • 48
Anshika
  • 1
  • 1

1 Answers1

2

you can use

 int i = scan.nextInt();
 scan.nextLine();
 double d = scan.nextDouble();
 scan.nextLine();
 String s = scan.nextLine();

Note that, Scanner.nextInt(), Scanner.nextDouble etc doesn't get the last next line. So you need to call them separately.

stinepike
  • 50,967
  • 14
  • 89
  • 108