Presentation is loading. Please wait.

Presentation is loading. Please wait.

Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.

Similar presentations


Presentation on theme: "Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at."— Presentation transcript:

1 Input & Output In Java

2 Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at dealing with data it still needs to translate that data into a format that is understandable to users. (OUTPUT) Users also have to provide information that the computer can understand (INPUT) The Java programming language uses several strategies to be able to handle input an output. Java treats input and output data as streams of bytes (groups of 8 bits with integer values)

3 Handling Input & Output - I/O Until now we have dealt with one program that is made up of only one file. Ex: Hello.java From this simple program we have been able to output information using the System.out.println(); statement. This works for simple text output. It does not work well for more complex outputs like pictures. Fortunately the Java programming language has files (programs) that can help handle more complex inputs and outputs.

4 Importing classes & packages A class is a collection of instructions and information. A package is a collection of classes which may used in your program. Think of a package as a tool box and the classes within it as tools. Different programs need different tools and include different packages. Classes and packages can be created elsewhere and then imported into your program.

5 The Scanner Class The scanner class helps handle input To import into your program use the import command Syntax is as follows: import java.util.Scanner; public static void main(String[] args) { Scanner input=new Scanner (System.in); //more lines of code }

6 In and Out classes The in class handles input The Out class handles output They have been created specifically for this course using the resource from The textbook “An Introduction to Computer Science Using Java” (John Carter). Instructions on how to use these classes are in the text: Appendix A.


Download ppt "Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at."

Similar presentations


Ads by Google