Guide to Object-oriented Programming With Java (University at Buffalo Version)
Chapter 6: Java Accepting and Displaying Data
There are certain Java concepts that will be used throughout this guide, including object (constructor, instantiation), class, data attributes, methods, encapsulation, information hiding, Polymorphism, and inheritance.
The Java System.outOutputStream
You can use the System.outOutputStream to display output. Usually System.out writes to the Eclipse console or the command ine window. System.out.print() displays the parameter values without putting a new line after the output. System.out.println() displays the parameter values and then prints a new line after the output. System.out.printf() allows you to provide "type" placeholders for the parameter values and does not print a new line after the output.
The Java java.text.DecimalFormat Library
You can use the java.text.DecimalFormat class in the java.text library to display formatted output. First, you need to add import java.text.DecimalFormat; before your class statement. Then you need to instantiate a DecimalFormat object with the pattern you want to use to display the data. Now you can use the format mathod.
The Java System.errPrintStream
You can use the System.errPrintStream to display errors.
The Java System.inInputStream
You can use the System.inInputStream to accept input. Usually System.in is connected to a keyboard reader or Scanner object.
Using a Scanner With the System.inInputStream
You can use the System.inInputStream to accept input. You need to import the java.io.IOException and java.utl.Scanner utility libraries.