Last Modified 2019.2.1
static import
Java 5 introduced a static import statement. You can omit the class name with static import statements when using static members.
package net.java_school.examples; import static java.lang.Math.*; public class StaticImportTest { public static void main(String[] args) { System.out.println(sqrt(4));//You can omit Math. } }
2.0
import java.util. *;
In the above import statement, * means all types in the java.util package.
import static java.lang.Math. *;
In the above import statement, * means all static variables and methods of the Math class. If you only want the sqrt() method of the Math class, modify the import statement as follows:
import static java.lang.Math.sqrt;