1

i have this code below, i ask why when i made array of subclass it work but when i made instance of class it dont work

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();


        }
    }
Hussein Alrubaye
  • 915
  • 8
  • 14

0 Answers0