Console input/output

Console input/output lets you display and read text: System.out.println and printf write, and Scanner reads standard input (System.in). printf formats with specifiers such as %d, %s, and %.2f. You need to handle the newline left behind by nextInt().

Example

Scanner sc = new Scanner(System.in);
int age = sc.nextInt();
System.out.printf("Age: %d%n", age);

Related concepts

The whole glossary