Console input and output

How to use output:

  • System.out.println("Welcome");
  • System.out.println("Welcome: " + userName);
  • System.out.println("Total: " + invoiceTotal);
  • System.out.println("\n");

How to use input:

Introduced in Java 1.5 was the Scanner class.

Each entry that a user makes is called a token. A user can input two or more tokens by separating them with whitespace.

import java.util.Scanner

Scanner sc = new Scanner(System.in);

String user = sc.next();

int count = sc.nextInt();