So say I have 3 classes, Tester, Fruit (superclass), and Apple (subclass)
I have written a new method in Apple (which extends Fruit). The method being:
public String getAppleColor()
Now say in Tester I have created an array of 10 Fruit
Fruit fruitArray = new Fruit[10]
and say I make one of them
fruitArray[3] = new Apple()
This is fine, since Apple is also of type Fruit. However I wish to use my getAppleColor() on this specific element of the array:
String appleColor = fruitArray[3].getAppleColor();
How come this is not working? When I look at useable methods on fruitArray[3] in eclipse, none of my Apple methods show up, but I made fruitArray[3] an Apple?