Код: Выделить всё
interface Fruit
{
public List getColors();
public List getChildren();
}
class FruitUtil
{
public static void readFruit(Fruit fruit)
{
// shows error : Type mismatch: cannot convert from element type Object to String
for(String color : fruit.getColors()) { }
// shows error : Type mismatch: cannot convert from element type Object to Fruit
for(Fruit thisFruit : fruit.getChildren()) { }
}
}
Но при использовании getColors() Fruit он возвращает List вместо List, несмотря на то, что он имеет точное тип возвращаемого значения.
Я что-то упустил?
Подробнее здесь: https://stackoverflow.com/questions/790 ... ic-in-java
Мобильная версия