【发布时间】:2013-05-11 20:13:48
【问题描述】:
我有一个类 A,其中有一个名为 B 的静态嵌套类:
import static A.B.*;
class A {
static class B {
static int x;
static int y;
}
public static void main(String[] args) {
System.out.println(x);
}
}
我想静态导入B 中的所有内容,但它不起作用:
$ javac A.java
A.java:1: package A does not exist
import static A.B.*;
^
A.java:9: cannot find symbol
symbol : variable x
location: class A
System.out.println(x);
^
2 errors
为什么?
【问题讨论】:
-
'静态内部'是一个矛盾的术语。
标签: java import compilation static package