This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

instanceof query  RSS feed

 
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
Sheriff
Posts: 23283
125
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!