Module-4-JAVA-INPUT-OUTPUT
Module-4-JAVA-INPUT-OUTPUT
Computer Programming 1
Java
Input/Output
Ms. Gemmarie T. Muñoz
TABLE OF CONTENTS
Java Output
Importing Packages
Method Description
nextBoolean() Reads a boolean value from the user
nextDouble() Reads a double value from the user
nextFloat() Reads a float value from the user
nextByte() Reads a byte value from the user
nextInt() Reads a int value from the user
nextShort() Reads a short value from the user
nextLong() Reads a long value from the user
nextLine() Reads a String value from the user
next().charAt(0); Reads a character value from the user
Note: We use different methods to read data of various types
User Input
String x;
Scanner s = new Scanner(System.in);
x = s.nextLine();
JOptionPane class
messageType Description
JOptionPane.ERROR_MESSAGE The error icon ( X ) is displayed in the dialog box
JOptionPane.PLAIN_MESSAGE
No icon appears in the for dialog box.