You are viewing a single comment's thread. Return to all comments →
Without scan.nextLine() not read from your next line.
if your input is:
42 3.1415 Welcome to HackerRank's Java tutorials!
the output is:
String: Welcome to HackerRank's Java tutorials! Double: 3.1415 Int: 42
So this time the output is correct but the input is not.
Check the box " Test against custom input" and play yourself.
Also next code works
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int i = scan.nextInt(); scan.nextLine(); Double d = scan.nextDouble(); scan.nextLine(); String s = scan.nextLine(); System.out.println("String: " + s); System.out.println("Double: " + d); System.out.println("Int: " + i); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all comments →
Without scan.nextLine() not read from your next line.
if your input is:
the output is:
So this time the output is correct but the input is not.
Check the box " Test against custom input" and play yourself.
Also next code works