Java 1.5's quirky new static import

David Flanagan has been experimenting with the new static import feature in Java 2 version 1.5, which provides a shorthand way to refer to class variables:

import static java.lang.System.out;

class SalutonMondo {
public static void main(String[] args) {
out.println("Saluton Mondo!");
}
}

That seems simple enough, but as Flanagan demonstrates, the static import keyword does some things you might not expect.

Add a Comment

These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. A comment may not include more than three links. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).