title: Java: How to check if an object is an instance of a non-static inner class, regardless of the outer object?
body: <p>If I have an inner class e.g.</p>
  
  <pre><code>class Outer{
      class Inner{}
  }
  </code></pre>
  
  <p>Is there any way to check if an arbitrary <code>Object</code> is an instance of any <code>Inner</code>, regardless of its outer object? <code>instanceof</code> gives false when the objects are not <code>Inner</code>s from the same <code>Outer</code>. I know a workaround is just to make <code>Inner</code> a static class, but I'm wondering if what I'm asking is possible.</p>
  
  <p>Example:</p>
  
  <pre><code>class Outer{
      Inner inner = new Inner();
      class Inner{}
  
      public boolean isInner(Object o){
          return o instanceof Inner;
      }
  }
  </code></pre>
  
  <p><br/></p>
  
  <pre><code>Outer outer1 = new Outer();
  Outer outer2 = new Outer();
  boolean answer = outer1.isInner(outer2.inner); //gives false
  </code></pre>