I've been casually programming in Java for a while, but I still have a few burning questions on the fundamentals. I've heard that I should use System.out.println() to display data from some people, and others have given me different ideas (like PrintStream or something else). What's the best way to print to console in Java?
If you are just starting and wanting to print some strings to the console then System.out.println() will be fine. Get your fundamentals down and then you can dive into the finer points of Java I/O.
System.out
is a PrintStream.
If your main goal is to interact with a console, look at java.io.Console
. If your main goal is to have some kind of logging, use a logging framework like the Java Logging API or log4j.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With