在java中的同一个类中调用静态方法内部的类

时间:2015-02-26 22:44:43

标签: java

我在下面有这个代码,我问为什么当我创建子类数组时它工作但是当我创建类的实例时它不起作用

public class Parent {
      class Nested {
        void anotherMethod() { System.out.println("nested"); }
        }

        public static void main(String[] args) {
            // this line is work even nested class isnot static
            Nested[]  s1=new  Nested[10];
            // this line dont work
             Nested  s2=new  Nested();


        }
    }

0 个答案:

没有答案
相关问题