java Programming Glossary: bananas
Generics-Get and Put rule http://stackoverflow.com/questions/1292109/generics-get-and-put-rule share improve this question Consider a bunch of bananas. This is a Collection extends Fruit in that it's a collection.. to it you might be trying to add an apple to a bunch of bananas which would definitely be wrong. You can add null to it as that..
Generics in Java http://stackoverflow.com/questions/1794842/generics-in-java a matter of logic even though counter intuitive a bag of bananas is NOT a bag of fruit... in a world of mutable objects the functional.. is a piece of fruit but you can't add an apple to a bag of bananas since an apple is not a banana . BTW this is very similar to..
Why we can't do List<Parent> mylist = ArrayList<child>(); http://stackoverflow.com/questions/5763750/why-we-cant-do-listparent-mylist-arraylistchild Then this program would have to be fine ArrayList Banana bananas new ArrayList Banana List Fruit fruit bananas fruit.add new.. Banana bananas new ArrayList Banana List Fruit fruit bananas fruit.add new Apple Banana banana bananas.get 0 That's clearly.. List Fruit fruit bananas fruit.add new Apple Banana banana bananas.get 0 That's clearly not type safe you've ended up with an apple..
|