This isn't quite an advanced question, so I'm moving it to the intermediate forum, but I'll follow up with you there once you post your example that didn't work. [ December 16, 2004: Message edited by: Jessica Sant ]
That cast doesn't work, becuase wild ISN'T a Pet. You constructed it as an Animal... it doesn't have the facilities to work as a Pet. If you had said:
Animal wild=new Pet();
you could cast down, becuase wild was constructed to be a Pet. Similarly, in your Graphics example, the author is assuming that the Graphics in question is a Graphics2d. If it turns out that it isn't and was cunstructed some other way, you'll get your ClassCastException.
dig? [ December 16, 2004: Message edited by: Nick George ]
I've heard it takes forever to grow a woman from the ground
Joined: Feb 24, 2004
So, does it mean that the Graphics object used in the paint() method is created by the Graphics2D constructor and is down casted as Graphics object?