Skip to main content
added 21 characters in body
Source Link

why don't you make lists of your interface?

List<iEntity> fruitList = ...; //list of interfaces
fruitList.add(new Apple()); //can be added because it implements iEntity
fruitList.add(new Pear()); //can be added because it implements iEntity

for (iEntity entity: fruitList){
    entity.update(); //each objects implements iEntity - no matter if pears or apples
}

why don't you make lists of your interface?

List<iEntity> fruitList = ...;
fruitList.add(new Apple()); //can be added because it implements iEntity
fruitList.add(new Pear()); //can be added because it implements iEntity

for (iEntity entity: fruitList){
    entity.update(); //each objects implements iEntity - no matter if pears or apples
}

why don't you make lists of your interface?

List<iEntity> fruitList = ...; //list of interfaces
fruitList.add(new Apple()); //can be added because it implements iEntity
fruitList.add(new Pear()); //can be added because it implements iEntity

for (iEntity entity: fruitList){
    entity.update(); //each objects implements iEntity - no matter if pears or apples
}
Source Link

why don't you make lists of your interface?

List<iEntity> fruitList = ...;
fruitList.add(new Apple()); //can be added because it implements iEntity
fruitList.add(new Pear()); //can be added because it implements iEntity

for (iEntity entity: fruitList){
    entity.update(); //each objects implements iEntity - no matter if pears or apples
}