System. Err: standard error output stream. This stream is opened and ready to accept output data. Usually, this stream corresponds to the display or another output target specified by the host environment or the user. By convention, this output stream is used to display error messages or other information that should be immediately noticed by users even if the user’s output stream has been redirected to a file or other target that is not normally continuously monitored
System. Out: standard output stream that is open and ready to accept output data. Typically, this flow corresponds to the display output or another output target specified by the host environment or the user
Using system.out.println and system.err.println to print the input content at the same time, the result is that the content you see is different from what you expect. The difference between the order and what you expect is not because of the difference between err and out, but because they are two streams and the output order is different because of the cache
1. System. Out. Println can be redirected to other output streams, so that you can’t see the printed object on the screen. System. Err. Println can only print on the screen, even if you redirect
2. When exporting information to the console, developers have two choices: system. Out and system. Err. Users are more likely to output system. Out than system. Err. It’s obvious
3. System. Out may be buffered, system. Err may not
4. System. Err and system. Out are error output and standard output. If you log with log4j and set the error level, the output of system. Err will be recorded in the log
5. The output devices are the same, so what you see is the same. System. Seterr and system. Setup are the methods to redirect the two streams
6. System. Err is not buffered, so the priority will be higher. System. Out needs buffering, so the priority will be lower