I am rewriting a Java book for beginners, and it seems to make so much sense
import static java.lang.System.out;
public class Greeting
public static void main(String args)
I would no longer have to
dissect the awful System.out.println("Hello, World!") expression.
(Ok, boys and girls. System is a class. System.out is
a static field of type PrintStream. That's another class. What is
static, you ask? It's what a TV set makes when it doesn't get a signal. No,
it's what you don't want in your dryer. Ok, whatever it is, you don't ever want
to do it in your code, unless it is also final. That means, you
can't change it. Oh, you spotted System.setOut.
Ditto with mathematical expressions. Doesn't
sin(angle * PI / 180)
look so much nicer than
Math.sin(angle * Math.PI / 180)
Ok, at least to that tiny fraction of the population who knows
The fact is, I don't recall ever seeing anyone using static import outside
JUnit 4, where it is justifiably popular to import
I am trying to get the reaction of the average Java coder here. Have you
switched from System.out to out with a static import?
Would you think it weird to look at other people's code that did that? Or would
you welcome it?