System.err are two standard output streams provided by the Java Runtime Environment (JRE) for writing text data to the console or a file.
The difference between
System.err is the intended purpose of the output stream:
System.out: This is the standard output stream, which is typically used to write normal program output to the console or a file. The data written to
System.outis typically displayed in black color in the console window.
System.out.println("This is normal output");
System.err: This is the standard error stream, which is typically used to write error messages or diagnostic information to the console or a file. The data written to
System.erris typically displayed in red color in the console window.
System.err.println("This is an error message");
System.out is used for standard program output, while
System.err is used for error messages or diagnostic information that should be distinguished from normal program output.
It's important to note that while
System.err are separate output streams, they may be displayed in the console window in an interleaved or unpredictable manner, depending on the operating system and the console configuration. As such, it's generally not a good idea to rely on the order or timing of messages written to
System.err when debugging or troubleshooting a program.