Tsallaka zuwa abun ciki
Justice Tech School

Output

println prints a line and moves to the next, print stays on the same line, and printf formats values with placeholders such as %d (integer), %s (text) and %.2f (decimal).

Example
System.out.println("Hello");
System.out.print("A");
System.out.print("B");
System.out.println();
System.out.printf("%s is %d years old, score %.1f%n", "Ada", 21, 91.256);

Result

Hello
AB
Ada is 21 years old, score 91.3

Exercise

Print without a new line.

System.out.("same line");

Quiz Test

Which placeholder formats an integer in printf?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.