Page 1 of 1

[HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]

Posted: Wed May 15, 2019 11:10 am
by natasci
Hi, at the page 308 given the code snippet:

Code: Select all

Mango m = new Mango();
Apple a = (Mango) m;
And then the explanation:
The compiler rejects the above code in spite of you guaranteeing that m will point to an Apple
at run time.
According to the explanation above shouldn't the code be:

Code: Select all

Mango m = new Mango();
Apple a = (Apple) m;

Re: [HD Pg 0, Sec. 11.3.1 - bridging-the-gap-between-compile-time-and-run-time]

Posted: Wed May 15, 2019 9:54 pm
by admin
You are right. It should be:
Mango m = new Mango();
Apple a = (Apple) m;

Added to errata. thank you for your feedback!