A shorter Java println

Java

Still using the beloved System.out.println() message for debugging, simple messages and so on? Short of creating your own static wrapper method with a simpler name (puts() or print() or printf() or yoDawg(), etc), you can also just do this:

import static java.lang.System.err;
import static java.lang.System.out;

[..]
public void birdIsTheWord() {
  out.println("Yay, that's marginally easier!");
  err.println("SNIDE RETORT: Not THAT much easier");
}

It’s old hat to lots of people, but I get enough “whoa, that’s cool!” responses from others when they see my code to think it’s not as well known as I thought.

Happy.slightly.less.verbose.coding! (^_^)


Imprint

This is one of about 5000 posts on Rubénerd. View the home page for the latest, or related posts also tagged with:

If you liked this post, feel free to buy me a coffee, leave me a comment on Twitter, or email me at weblog2017@rubenschade.com. Thanks :).