Campbell Ritchie wrote:Please give us fuller details of the book, including authors. Is it Boyarsky and Selikoff?
The full details are in the Java® Language Specification (=JLS). The JLS and the language are written on the assumption that programmers are competent and when they wrote code the know what they are doing. If you write a narrowing reference conversion, it is conceivable that your no 2 class has a subtype implementing the InOne interface, so it “believes” you,even though you are “lying” to it with that cast.
Yes, its OCP JSE11 book, from selikoff.
You said, what i meant in the previous comment.
Java believes that a child class has a subtype implementing the InOne interface, thats why if I mark the parent class as final, wont compile.
Look the example again.(works if concrete2 its not final)