import java.util.Scanner;

/**
 * An example that illustrates an inconvenience assoicated with
 * the behavior of Scanner objects.
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class ScannerInconvenienceExample
{
    /**
     * The entry point of the application.
     *
     * @param args The command-line arguments (which are ignored)
     */
    public static void main(String[] args)
    {
        int     age;
        Scanner keyboard;        
        String  name;
        
        keyboard = new Scanner(System.in);
        
        // If you run this program you won't be able to enter your
        // name because the return you enter after your age will
        // be considered the "next line"
        System.out.print("Enter your age: ");
        age = keyboard.nextInt();
        System.out.print("Enter your name: ");
        name = keyboard.nextLine();

        keyboard.close();
    }
}

