Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

instanceof query

 
geet kaur
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys
do we check the type of the refernce varaible against the type provided on the right side of the operator or we just compare the object it is refering to?
 
Henry Wong
author
Marshal
Pie
Posts: 21220
81
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do we check the type of the refernce varaible against the type provided on the right side of the operator or we just compare the object it is refering to?


Obviously, it is checking the type of the actual object being referred to to a specific type. Checking the type of the reference variable is kinda silly -- as you can figure it out before you compile and replace the expression with a true or false.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic