The static import feature of Java 5 facilitate the java programmer to access any static member of a class directly. There is no need to qualify it by the class name.
***************************** Simple Example of static import *****************************
import static java.lang.System.*; class StaticImportExample{ public static void main(String args[]){ out.println("Hello");//Now no need of System.out out.println("Java"); } } ================================ Output ================================== Hello Java -------------------------------------------------------------------------------------------------------------------------
************************** difference between import and static import **********************
The import allows the java programmer to access classes of a package without package qualification whereas the static import feature allows to access the static members of a class without the class qualification. The import provides accessibility to classes and interface whereas static import provides accessibility to static members of the class.
|