Class question
-
I have a dum guestion... how do i declare an array of clases, an array in wich every element is a class i tried class SomeClass { public int x; public int y; }; SomeClass[] a=new SomeClass[5]; everything goes ok. when i run the prorgam and i try smth like : a[3]=4; the program throws an exception.. pls help me..
-
I have a dum guestion... how do i declare an array of clases, an array in wich every element is a class i tried class SomeClass { public int x; public int y; }; SomeClass[] a=new SomeClass[5]; everything goes ok. when i run the prorgam and i try smth like : a[3]=4; the program throws an exception.. pls help me..
-
For each class in SomeClass[] you need to do a SomeClass[i] = new SomeClass(constructor) Then you can access the values like: SomeClass[3].x = value;
-
If you don't need one, then just don't declare it. A simple SomeClass[i] = new SomeClass(); will be enough then.