title: Test if a class contains an instance variable based on its name
body: <p>Sometimes I need to test which class has declared some variable(s), is there another way how to test that, if concrete class contains variable with some name</p>
  
  <pre><code>try {
     testLocalVariable = (String) (this.getClass().getDeclaredField("testVariable").get(this));
  } catch (NoSuchFieldException ex) {
  } catch (SecurityException ex) {
  } catch (IllegalArgumentException ex) {
  } catch (IllegalAccessException ex) {
  }
  </code></pre>