Feature Overview
This feature imports static fields and methods from classes and enables them to be used without prefixing class names.
This feature imports static fields and methods from classes and enables them to be used without prefixing class names.
None
import static Math;
public class ImportStaticDemo {
public static void main() {
Double d = PI;
Integer result = abs(-1);
}
}
public class ImportStaticDemo {
public static void main() {
Double d = Math.PI;
Integer result = Math.abs(-1);
}
}
Static importing depends on type checking. Should type checking go wrong, static importing will fail.
Contribute on Github! Edit this section.