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);
}
}
Asked
Active
Viewed 32 times
-2
![](../../users/profiles/2864275.webp)
Iłya Bursov
- 20,672
- 4
- 30
- 48
![](../../users/profiles/7816572.webp)
Anshika
- 1
- 1
-
add `scan.nextLine();` after `scan.nextDouble();` – Iłya Bursov Apr 04 '17 at 20:05
-
what is your error / output? – victor Apr 04 '17 at 20:05
1 Answers
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.
![](../../users/profiles/603742.webp)
stinepike
- 50,967
- 14
- 89
- 108