title: How to get warnings for variable hiding in Java inheritance?
body: <p>I encountered a bug in a Java program because I did not understand hiding with inheritance.</p>
  
  <p>My bug came down to this:</p>
  
  <pre><code>class Animal {
      int numPaws = 4;
  }
  
  class Snake extends Animal {
      int numPaws = 0;
  }
  
  class Runner {
      public static void main(String[] args) {
          Snake s = new Snake();
  
          /* There two different copies of this variable,
             but no override warning as there would be with a method. */
          System.out.println(s.numPaws);
          System.out.println(((Animal)s).numPaws);
      }
  }
  </code></pre>
  
  <p>Now I want to ask: </p>
  
  <p>If I do this with methods, I get warning and told to use @Override decorator. Why do I get no warning with variables? </p>
  
  <p>How do I check for this in future?</p>
  
  <p>Also why does Java provide no warning system? Or, why does it allow it with variables?</p>