Hey, I'm tring to learn Java, but i don't uderstand why I have do this:
APFour bucky[] = new APFour[2]; //This to define what we should use to call the methods. (bucky[0] and bucky[1] is the names) bucky[0] = new APThree(); bucky[1] = new APTwo(); //This is just to loop thought the methods. for(int x = 0; x<=1; x++){ bucky[x].eat(); } }
I don't understand why I have to put APFour[2] and not just APFour();
My otherclasses:
One (Sub Class):
void eat(){ System.out.println("This STARTER is great. "); }
Two (Sub Class):
void eat(){ System.out.println("This DINNER is great. "); }
Three (Super Class):
void eat(){ System.out.println("This food is great. "); }
Thanks for your time!