We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here is it. It works for all the test cases
The first - String s = sc.nextLine();
reads "\n" . Hence some of you got the error.
and then second s=sc.nextLine();
reads the complete line
Scanner sc = new Scanner(System.in) ;
int i = sc.nextInt();
double d = sc.nextDouble();
String s = sc.nextLine();
s=sc.nextLine();
System.out.println("String: "+s);
System.out.println("Double: "+d);
System.out.println("Int: "+i);
Cookie support is required to access HackerRank
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 →
Here is it. It works for all the test cases The first - String s = sc.nextLine(); reads "\n" . Hence some of you got the error. and then second s=sc.nextLine(); reads the complete line