Static import feature was introduced in Java 5. Static import allows you to access the static member of a class directly without using the fully qualified name.
Static import in Java allows to import static members of the class and use them, as they are declared in the same class.
package com.java.core;
import static java.lang.System.*;
public class StaticImportsExample {
public static void main(String[] args) {
// Accessing static method with Class name
System.out.println(System.nanoTime());
// Accessing static method without Class name -using static import
System.out.println(nanoTime());
System.out.println(currentTimeMillis());
}
}
771135565412278
771135565725051
1587528008813