Question:
What is a Static Import?
Answer:
Static imports allow the static items of one class to be referenced in another without qualification.
Code:
import static java.lang.Math.PI; import static java.lang.Integer.MAX_VALUE; public class StaticImportStatements { public static void main(String[] args) { System.out.println("PI: " + PI); System.out.println("Int max: " + MAX_VALUE); } }
Output:
$ java StaticImportStatements PI: 3.141592653589793 Int max: 2147483647