Java 5: Static import


Static import is the feature introduced in java 1.5 release. By using static import, we can directly access static members and methods of another class without class name or object name.

Let us understand this with an example,

package java5.staticimport;

import static java.lang.System.*;

public class StaticImportDemo {
    public static void main(String[] args) {
        out.println("Hello..Welcome to Java 5");
    }
}

Output:
Hello..Welcome to Java 5

Comments

Popular posts from this blog

Java 5: Varargs

Method Overloading Vs Method Overriding

Difference between "== operator" and "equals() method"