Output using System.out.

From CompSciWiki
Revision as of 18:29, 3 March 2007 by Umhalle1 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Output using System.out.

Java uses System.out. for program output.

Printing text to the screen

To print text to the screen you can use:

System.out.println("text");

or

System.out.print("text");

Whatever you put inside of the quotes will be printed to the screen. The difference between System.out.println and System.out.print is that System.out.println will print a newline after the text unlike System.out.print which just prints the text.

Example

This program prints the message "Go Bisons!" to the screen.

public class Output
{
  public static void main(String args[]) 
  {
    System.out.println("Go Bisons!");
  }
}