I have 2 classes: class A and class B, both classes are packageless (in default package). I want to import and use A's static variable into B. How do I do that so that it compiles?
The following is not compiling:
A.java
public class A {
public static int x = 10;
}
B.java
import static A.x;
public class B {
public static void main(String[] args) {
System.out.println(x);
}
}
Compiler output: B.java:1: error: static import only from classes and interfaces