一道Inner Class的疑惑

来源:百度知道 编辑:UC知道 时间:2024/05/10 14:46:53
为什么在别的类里面就不能直接调用另一个类的static inner class啊?
比如这个程序:
class Line{
public static class Point{}
}
class Triangle{
// insert here
}
为什么不能直接写成Ponit p=new Point()呢?

静态内部类相当于静态变量,其他内部类可以引用!
Point是Java已经封装的,所以为了避免命名空间冲突,所以不能直接用!

把内部类型想象成属性就好理解了
你可以写InnerTest.Point p = new InnerTest.Point();