Read int from console using Scanner - Java File Path IO

Java examples for File Path IO:Scanner

Description

Read int from console using Scanner

Demo Code

import java.util.Scanner;

public class EndOfFile {

    public static void main(String cLA[]) {

        Scanner input = new Scanner(System.in);

        int aNumber, anotherNumber;

        while (input.hasNextInt()) {
            aNumber = input.nextInt();/*from   w w w . j ava 2s. c  o  m*/
            anotherNumber = input.nextInt();
        }
    }
}

Related Tutorials