title: Variable shadowing and inherit concrete method from abstract class in java
body: <p>I'm working on an assignment has a class hierarchy like blow:</p>
  
  <p>abstract EventClass</p>
  
  <p>someEventClass1 extends EventClass</p>
  
  <p>someEventClass2 extends EventClass</p>
  
  <p>inside briefly:</p>
  
  <pre><code>abs EventClass{
  //not in use just make it compile
  int priority;
  concrete compareTo(){
     //need access priority when working in subclass}
  }
  someEventClass1 extends EventClass{
    int priority;
  }
  </code></pre>
  
  <p>in my EventClass I have a concrete method compareTo(Event in), which i expect it inherit by all subclasses</p>
  
  <p>it will compare the priority(a int) of different events.
  Obviously, inside this method I need to access priority within the subclasses. To make it compile I have to add a int priority in EventClass, and I was thinking I can shallow it in subclasses and it will works just fine with the compareTo inherited.</p>
  
  <p>However, It's not working properly, it seems the compareTo is not working.</p>
  
  <p>If I erase the int priority and compareTo() in EventClass, put the compareTo into all my subclasses(ugly duplicated code). It works just fine...</p>
  
  <p>Can some one help me to design this? Or tell me what I missed..</p>
  
  <p>Thanks for any help!</p>