Kamis, 29 Mei 2014

Eclipse shortcut to System.out.println in Java program - Tips




Eclipse IDE provides quick shortcut keys to print System.out.println
statement in Java but unfortunately not every Java programmers are
familiar of that.  Even programmers with 3 to 4 year of experience sometime doesn't know this useful Eclipse shortcut to generate
System.out.println messages.  This Eclipse tips is to help those guys. Let me ask you one
question, How many times you type
System.out.println in your
Java program?  I guess multiple time,  while doing programming, debugging
and testing small stuff.  
System.out.println
is most preferred way to print something on console because it doesn’t
required setup like configuring Log4J or
java.util.Logger . Though I
recommend using logging for better information display in production
code
, nobody can undermine importance of
System.out.println statement
in Java. On the quest of learning Eclipse shortcut, some of them which I have
discussed in my list of Top
30 Eclipse shortcut for Java programmers
,  I found a very useful Eclipse shortcut for generating
code for
System.out.println statement in Java source
file. By using this Eclipse shortcut you can create
System.out.println() messages in
60% less time,  as you only need to type
the message. This Eclipse shortcut will place your cursor right in the place,
where it should be i.e. inside
System.out.println method.




Eclipse shortcut for System.out.println



How to generate system.out.println in Eclipse IDE


In order to generate code for System.out.println statement
in your Java file, you can use following Eclipse shortcut keys. Just type
"sysout" in your Java editor and press ctrl + space, which triggers code completion. This will expand sysout into System.out.println("") and place
your cursor inside
println() method argument to enter
messages. This is in my knowledge quickest way of writing
System.out.println
statement in Java code. Though you can also use static import feature of
Java 5 to import
System.out static
variable
and simply use them as
out.println(), which can
save you couple of keystrokes but that has its own problem in terms of reduced
readability and chance of conflict, In case you happen to have another variable
with identifier
"out". This Eclipse shortcut to create System.out.println() statement
is best in my opinion. Similar to
sysout shortcut,
you also have Eclipse shortcut for generating
System.err.println()
statements. Just type
syserr and press ctrl + space, it will generate System.err.println statement and
place the cursor in right place to type message.





As I have always said learn new Linux command to improve
productivity in UNIX
based system s learn similarly Eclipse shortcuts to
work faster in Eclipse and learn Java and open source API to reduce development
time of new projects. I'll keep sharing useful Eclipse shortcut as and when I
will find them.  Let me know if you come
across any interesting Eclipse shortcut like this.





Other useful Eclipse tips and tricks from Javarevisited Blog






























Source:http://javarevisited.blogspot.com/2012/10/eclipse-shortcut-to-systemoutprintln-in-java.html

Tidak ada komentar:

Posting Komentar