Output with System.out in Java
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.
Writes text with no trailing newline, so the next output continues on the same line.
println
Writes text followed by a newline, moving subsequent output to a new line.
Automatic toString conversion
Passing a non-String value to print or println calls its toString() method automatically to get displayable text.
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.
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.
public class OutputDemo { public static void main(String[] args) { System.out.print("Loading"); System.out.print("..."); System.out.println(" done!"); System.out.println(42); }}Recommended resourcesAffiliate links · may earn us a commission
Recommended for learners
Practice what you learned
Re-implement each visualized algorithm in Java yourself — building beats watching.