jcadima
9/6/2016 - 6:42 PM

Java Scanner input

Java Scanner input

/*
After supplying data for int, we would hit the enter key. 
What nextInt() and nextDouble() does is it assigns integer to  the
appropriate variable and keeps the enter key unread in thekeyboard buffer. 
so when its time to supply String the nextLine() will read 
the enter key from the user thinking that the user has entered the enter key.
(that's we get empty output) . 
Unlike C, there is no fflush() to clean buffer, 
so we have to flush by not taking it in variable.
*/

import java.util.*;
import java.io.*;

public class Solution {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int myInt = scan.nextInt();
        int myInt2 = scan.nextInt();
         String input = scan.nextLine();

        System.out.println(a);
        System.out.println(myInt) ;
        System.out.println(myInt2) ;
    }
}