When using == to compare reference variables, the compiler will verify that the classes are the same or in the same inheritance hierarchy, otherwise it'll throw a compiler error
can you guys provide example(s) of this statement? specially when the compiler might throw a compilation error...
I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Andres, is exactly the same as with the instanceof operator or casting. If in the above example you try: if (d instanceof D2) {} // compiler error! or: d = (D2) d2; // compiler error! They must be in the same inheritence hierarchy. Miki
Miki<br /> <br />SCJP 1.4, SCBCD 1.3
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop