A shorter Java println

Software

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! (^_^)

Author bio and support

Me!

Ruben Schade is a technical writer and IaaS engineer in Sydney, Australia who refers to himself in the third person in bios. Wait, not BIOS… my brain should be EFI by now.

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite cloud infrastructure provider.

You can leave me a comment by contacting me, and I might publish your thoughts. Please read the FAQs first though.

If you found this post helpful or entertaining, you can shout me a coffee or buy some silly merch. Thanks!