Return to Unit Menu | Java Main Page | | Terms of Use

Obtaining Input

Input is difficult in Java.  Many authors of introductory textbooks provide their own input routines, so students can get input easily from the keyboard.  So be aware that different programmers may be using different input commands.

We will be using a library for obtaining keyboard input called the BreezyGUI.  The necessary files for using BreezyGUI are free and can be found at the BreezyGUI website.

The available methods used for obtaining input are displayed in the chart below.  Each of these methods accepts input followed by the pressing of the enter key.  Notice that the type of desired response is indicated in the command statement.  The user's prompt (the instructions to the user) is also entered within the command.

A listing of input methods from BreezyGUI:

1.  Console.readInt("Enter number") -- prompts the user and waits for integer input.

2.  Console.readDouble("Enter amount") -- prompts user and waits for double input.

3.  Console.readChar("Enter a letter") -- prompts user and waits for character input

4.  Console.readLine("Enter string") -- prompts user and waits for string input.

5.  Console.pause() --- Used with non-GUI applications to pause execution until the user
                                   hits the Enter key.  The user prompt is automatically produced.

Return to Unit Menu | Java Main Page | | Terms of Use