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.
Sometimes you have to clear the buffer to print the strings by command sc.nextLine();, here is my correct code:-
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
double y = sc.nextDouble();
sc.nextLine();
String s = sc.nextLine();
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all comments →
Sometimes you have to clear the buffer to print the strings by command sc.nextLine();, here is my correct code:- import java.util.Scanner;
public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x=sc.nextInt(); double y = sc.nextDouble(); sc.nextLine(); String s = sc.nextLine();
} }