Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make System.out.println() shorter

Tags:

java

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.

like image 607
Eugene Avatar asked Jul 23 '10 17:07

Eugene


People also ask

How do I make system out Println faster?

Just type syserr and press ctrl + space, it will generate System. err. println statement and place the cursor in right place to type message.

How do you write system out Println In short?

println() line in eclipse without typing the whole line type sysout and press Ctrl + space.

How do I make system out Println faster in Java IntelliJ?

In IntelliJ IDEA, type sout and press the Enter or Tab button from your keyboard to generate System. out. println() automatically.

What is the shortcut for system out Println in Netbeans?

Type "sout" then hit tab.


2 Answers

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!');  
like image 65
bakkal Avatar answered Sep 22 '22 02:09

bakkal


void p(String l){ System.out.println(l); } 

Shortest. Go for it.

like image 22
rup Avatar answered Sep 25 '22 02:09

rup