What is Static Import in Java?

Static Import:

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.

Advantage of static import:

  • Less coding is required if you have access any static member of a class oftenly.

Disadvantage of static import:

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");  



Leave a Reply