Learn Java
import com.learnjava.ioformatting.OutputPrint;

Output with System.out in Java

@Concept

System.out is Java's standard output stream, offering three main ways to write to it: print (writes text with no trailing newline), println (writes text followed by a newline), and printf (writes using a format string with placeholders, covered in the next topic). Nearly any value can be passed directly to print or println — Java calls toString() on non-String arguments automatically, which is why printing an int, a boolean, or a custom object each just works without manual conversion.

System.err is a second, separate output stream meant specifically for error messages. By default both System.out and System.err display in the same terminal, but they can be redirected independently — exactly why logging frameworks and command-line tools route errors through System.err rather than System.out.

@HowItWorks
1

print

Writes text with no trailing newline, so the next output continues on the same line.

2

println

Writes text followed by a newline, moving subsequent output to a new line.

3

Automatic toString conversion

Passing a non-String value to print or println calls its toString() method automatically to get displayable text.

4

System.err

A separate output stream meant for error messages, which can be redirected independently of System.out even though both usually appear in the same terminal.

5

Building output incrementally

Several print calls in a row build up one line piece by piece, only ending it once a println — or a print with an embedded newline — actually appears.

@Example
public class OutputDemo {
public static void main(String[] args) {
System.out.print("Loading");
System.out.print("...");
System.out.println(" done!");
System.out.println(42);
}
}
Output
Loading... done!
42
1The two print calls each add text to the same line without starting a new one.
2println(" done!") finally adds a newline, ending that first line.
3println(42) passes an int directly — Java converts it to the text "42" automatically before printing.
4Two lines of output result: the built-up "Loading... done!" line, then "42" on its own line.
@UseCases
Building a progress indicator or status line piece by piece across several print calls
Printing a variable of any type without manually converting it to a String first
Separating routine output from error output by routing errors through System.err
Choosing print over println when a prompt should keep the cursor on the same line as user input

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in Java yourself — building beats watching.