I have an interface like so:
public interface FruitGetter {
public Fruit getFruit();
public List<Fruit> getFruits(int numFruit);
}
Fruit is an interface that I may implement for different types of fruit.
My confusion comes from the fact that implementing the two methods above doesn't seem to be consistent:
@Override
public Apple getFruit(){return new Apple();}
@Override
public List<Apple> getFruits(int numFruit){ //you get the idea}
Can someone please explain why the second implementation is an incompatible return type, while the first method seems to work correctly?