40 likes | 281 Views
INFT11-110/71-110 Keyboard Input. Class Keyboard provides a way to read each of the primitive types and also Strings from the keyboard: Keyboard.readInt() reads an int Keyboard.readByte() reads a byte Keyboard.readShort() reads a short Keyboard.readLong() reads a long
E N D
Class Keyboard provides a way to read each of the primitive types and also Strings from the keyboard: Keyboard.readInt() reads an int Keyboard.readByte() reads a byte Keyboard.readShort() reads a short Keyboard.readLong() reads a long Keyboard.readFloat() reads a float Keyboard.readDouble() reads a double Keyboard.readChar() reads a char Keyboard.readBoolean() reads a boolean Keyboard.readString() reads a String Keyboard is based on the Keyboard class from the textbook. A Class to Read from the Keyboard Reading input from the keyboard (or anywhere, really) is quite complicated in Java We will use a special class, Keyboard, to simplify the process • You don’t need to understand how Keyboard works yet • You do need to be able to follow these instructions to incorporate the class into your programs
Making This Happen 1. Download Keyboard.java from the webpage and store it in a central location 2. Make a new project as normal and create a main program such as the one on the previous slide, or the one from the webpages 3. Select “Add Class from File” from the Edit menu of the Project window