如何使System.out.println()更短 [英] How to make System.out.println() shorter
问题描述
请告诉我在哪里可以找到lib以便使用 System.out.println()
的较短表达式,以及我应该在哪里放置该库。
Please advice on where can I find the lib in order to use the shorter expression of System.out.println()
and where should I place that lib.
推荐答案
记录库
您可以使用日志库而不是重新发明轮。例如, Log4j 将提供不同消息的方法,例如 info ()
, warn()
和 error()
。
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()
.
或者只需制作一个 println
方法,并自行调用它:
or simply make a println
method of your own and call it:
void println(Object line) {
System.out.println(line);
}
println("Hello World");
IDE键盘快捷键
IntelliJ IDEA和NetBeans:
您键入 sout
然后按 TAB ,并为它键入 System.out.println()
,光标位于正确的位置。
you type sout
then press TAB, and it types System.out.println()
for you, with the cursor in the right place.
Eclipse:
键入 syso
然后按 CTRL + SPACE 。
其他
查找你最喜欢的文本编辑器/ IDE的插件插件
Find a "snippets" plugin for your favorite text editor/IDE
import static java.lang.System.out;
out.println("Hello World");
探索JVM语言
Scala
Explore JVM languages
Scala
println("Hello, World!")
Groovy
Groovy
println "Hello, World!"
Jython
Jython
print "Hello, World!"
JRuby
JRuby
puts "Hello, World!"
Clojure
Clojure
(println "Hello, World!")
Rhino
Rhino
print('Hello, World!');
这篇关于如何使System.out.println()更短的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!