• Post Reply Bookmark Topic Watch Topic
  • New Topic

instanceof and casts  RSS feed

 
Anna Dow
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!