title: How to avoid instanceof in Java
body: <p>In my application I have a 2d array of entities to represent a grid. Each location in the grid can either be empty or occupied by an entity (in this case it's just a person or wall). Right now I use <code>instanceof</code> to check whether an entity is a person or a wall. </p>
  
  <p>I was thinking of giving each entity a method which returns an <code>enum</code> stating their type so i.e. a wall entity would return <code>EntityType.WALL</code>. I was wondering if this is the best idea to remove the use of <code>instanceof</code> or is <code>instanceof</code> suitable in this scenario?</p>