Logging libraries
You could use logging libraries instead of re-inventing the wheel. Log4j for instance will provide methods for different messages like info()
, warn()
and error()
.
Homemade methods
or simply make a println
method of your own and call it:
void println(Object line) {
System.out.println(line);
}
println("Hello World");
IDE keyboard shortcuts
IntelliJ IDEA and NetBeans:
you type sout
then press TAB, and it types System.out.println()
for you, with the cursor in the right place.
Eclipse:
Type syso
then press CTRL + SPACE.
Other
Find a "snippets" plugin for your favorite text editor/IDE
Static Import
import static java.lang.System.out;
out.println("Hello World");
Explore JVM languages
Scala
println("Hello, World!")
Groovy
println "Hello, World!"
Jython
print "Hello, World!"
JRuby
puts "Hello, World!"
Clojure
(println "Hello, World!")
Rhino
print('Hello, World!');
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…