Home > DeveloperSection > Interviews > What is static import ?

Posted on    April-22-2015 12:40 AM

 Java Java 
Ratings:
 1 Answer(s)
  430  View(s)
Rate this:

Mayank Tripathi
Mayank Tripathi

Total Post:807

Points:4035
Posted on    April-22-2015 12:40 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick