Get rid of System.out

Or how to replace annoying System.out.println with concise println

Some features of Java are annoying for me, especially after several years of Scala experience. First of all: why should I use System.out.println instead of println!

It appears , that this problem can be solved easily:


public interface Printer {
    
    static <T> void println(T str) {
        System.out.println(str);
    }
    static <T> void print(T str) {
        System.out.print(str);
    }
    
}

Now one can import these static methods:


import static Printer.*;

Et voila!


println("I can print in Java  Scala way!");

See it on github

Please follow and like us:
Tweet 20

About Alexandre Kremlianski

Scala / Scala.js / JavaScript programmer

Page with Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.