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.
explanation ==>
i use scan.nextline() method before declaring string bcoz we have to first clear buffer so i used scan.nextline() method to cleare buffer
.....................................
my code is
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();
scan.nextLine(); // clear buffer by this
String s=scan.nextLine();
// Write your code here.
Java Stdin and Stdout II
You are viewing a single comment's thread. Return to all comments →
explanation ==> i use scan.nextline() method before declaring string bcoz we have to first clear buffer so i used scan.nextline() method to cleare buffer ..................................... my code is
import java.util.Scanner;
public class Solution {
double d=scan.nextDouble(); scan.nextLine(); // clear buffer by this String s=scan.nextLine(); // Write your code here.
}