This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes instanceof and casts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "instanceof and casts" Watch "instanceof and casts" New topic
Author

instanceof and casts

Anna Dow
Greenhorn

Joined: Jun 04, 2002
Posts: 18
Hi, all,
here is my question:
It looks that if returned true, then the cast is always possible.
(That is, the code like:

will never give a ClassCastException.) Is it true ?
Thanks, Anna
Gautam Sewani
Ranch Hand

Joined: Apr 19, 2002
Posts: 93
Yeah thats true.
But the code which you gave wont compile
coz you didn't use the if statement properly

should be made


Regards
Gautam
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: instanceof and casts