I'm reading
java 8 OCP guide :OCP_ Oracle Certified Professional Java SE 8 Programmer II Study Guide_ Exam 1Z0-809-Sybex
In a part of the book, the authors talk about lower bound and gives the following example to explain the concept :
and said that :
With a lower bound, we are telling Java that the list will be a list of String objects or a list of some objects that are a superclass of String.
therefor I understand that lower bound is used to bound the generic with the object or any superClass of it and
not a subClass.
but when I tried it I find the oposite :
Also in the book there is that part that I do not understand :
Line 3 references a List that could be List<IOException> or List<Exception> or
List<Object>. Line 4 does not compile because we could have a List<IOException> and
an Exception object wouldn’t fit in there.
Line 4 is fine. IOException can be added to any of those types. Line 5 is also fine. File-
NotFoundException can also be added to any of those three types. This is tricky because
FileNotFoundException is a subclass of IOException and the keyword says super. What
happens is that Java says “Well, FileNotFoundException also happens to be an IOException,
so everything is fine.”