Tuesday, February 3, 2009

Did you know: Static import

Static Import is a very simply and unnecessary opportunity in Java.

Static Import

The static import construct allows unqualified access to static members without inheriting from the type containing the static members. Instead, the program imports the members, either individually:

import static java.lang.Math.PI;
or:

import static java.lang.Math.*;

Once the static members have been imported, they may be used without qualification:

double r = cos(PI * theta);

It's easy and unnecessary as I said.

No comments: