The scenario. I\'m writting game-related code. In that game a Player
(its also a class) has a list of Item
. There are other types of items that inhe
You should rethink your structure, instanceof
in non-meta code is almost always a sign for an anti-pattern. Try to define the behaviour all Item
s have in common (like having a picture, a description and something happening when you click on them) in the Item
-class/interface, making use of the abstract
-keyword if appropiate, and then use polymorphism to implement the specifics.