title: How to instantiate a super class static variable in sub class as final
body: <p>I am simulating a parking lot application. And have a class <code>Vehicle</code> which is abstract and extended by concrete classes like <code>Car</code>, <code>Truck</code> etc. I have a variable <code>parkingFare</code> which for each sub class of <code>Vehicle</code> will be instantiated as class variable and final so that all instances of that particular class can use the same value. e.g If I set <code>parkingFare</code> for <code>Car</code> as $2 it should be the same for all instances of <code>Car</code>. The problem is I am unable to access this variable in my concrete class as class variable.  </p>
  
  <pre><code>public abstract class Vehicle {
  
   String plateNo;
   LocalTime startTime;
   static int parkingFare;
   public abstract int getFare();
   public abstract String getPlateNo();
   public abstract LocalTime getParkedTime();
  
  }
  
  
   public class Car extends Vehicle {
  
    final parkingFare = 2; // how I want to instantiate it.
     public Car(String plateNo){
      this.plateNo = plateNo;
      this.startTime = LocalTime.now();     
     }
  
     @Override
     public LocalTime getParkedTime(){
      return startTime;
     }
  
     @Override
     public String getPlateNo(){
      return plateNo;
     } 
  
     @Overrid
     public int getFare(){
      return parkingFare;
     }   
  }
  </code></pre>