WHAT IS STATIC IMPORT ?

Mayank Tripathi

Total Post:807

Points:4035
Posted by  Mayank Tripathi
Java 
 638  View(s)
Ratings:
Rate this:
  1. Mayank Tripathi

    Post:807

    Points:4035
    What is 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.

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!