Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 1: Intro Lesson 4: Output.

Similar presentations


Presentation on theme: "Unit 1: Intro Lesson 4: Output."— Presentation transcript:

1 Unit 1: Intro Lesson 4: Output

2 Output Methods Output methods allow the program to display information such as text, symbols, numbers, the result of calculations or the value of variables Most often Output is used to ask to the user for certain information, or to display a result Output Method 1: System.out.print(“ “); Output Method 1: System.out.println(“ “); Output Method 2: JOptionPane.showOutputDialog(“ “);

3 Print Simple Consecutive print statements display on the same line
Can only be used in an IDE or the Command Line

4 Print Line Simple Consecutive print statements display on separate lines Can only be used in an IDE or the Command Line

5 JOptionPane.showOutputDialog(“ “);
Slightly more complicated Works outside of the IDE or Command Line User – friendly interface Displays a popup window with the output dialog

6 Use of Print Create an initialized variable of any data type to display its value (Optional) Create an output statement System.out.print(“How about some input?”); int myVariable = 100; System.out.print(myVariable); String myVariable = (“Hello there!!!”);

7 Use of Print Line Create an initialized variable of any data type to display its value (Optional) Create an output statement System.out.println(“How about some input?”); int myVariable = 100; (Optional) System.out.println(myVariable); String myVariable = (“Hello there!!!”); (Optional)

8 Use of JOptionPane Output
Import statement Create an initialized variable of any data type to display its value (Optional) Create an output statement Import javax.swing.JOptionPane; JOptionPane.showOutputDialog(“You don’t need a variable for me”); int myVariable = 100; (Optional) JOptionPane.showOutputDialog(myVariable); String myVariable = (“Hello there!!!”); (Optional)


Download ppt "Unit 1: Intro Lesson 4: Output."

Similar presentations


Ads by Google