Skip to main content

Static Imports -- not a clean job?

Posted by km on December 23, 2006 at 5:22 PM PST

We have been requested to use static imports sparingly. I like that advice. Use your judgment to actually use this support.

But frankly, articles, presentations I have seen use the stdout, the "out" field of java.lang.System as imported statically. But, the following program does not compile:

class Format {
public static void main(final String[] args) {
out.format("Hello, World!");
}
}

Why?

Because I did not do: import static java.lang.System.out!

Why are all public members of the System classes not automatically
statically imported, like the System classes are imported?

Is there a problem with this expectation? Would community like implicit static import of public members of java.lang.*?

Related Topics >>