title: Class inheritance
body: <p>I have the following code, that works:</p>
  
  <pre><code>public class Bicycle {
  
      int cadence = 0;
      int speed = 0;
      int gear = 1;
  
      void changeCadence(int newValue){
          cadence = newValue;
      }
  
      void changeGear(int newValue){
          gear = newValue;
      }
  
      void speedUp(int increment){
          speed = speed + increment;
      }
  
      void applyBrakes(int decrement){
          speed = speed - decrement;
      }
  
      void printStates(){
          System.out.println("cadence: " + cadence + "; speed: " + speed + "; gear: " + gear);
      }
  
      public static void main(String[] args) {
  
          // Create two different 'Bicycle' objects:
          Bicycle bike1 = new Bicycle();
          Bicycle bike2 = new Bicycle();
  
          // Invoke methods on the two new objects:
          bike1.changeCadence(50);
          bike1.speedUp(10);
          bike1.changeGear(2);
          bike1.printStates();
  
          bike2.changeCadence(45);
          bike2.speedUp(15);
          bike2.changeGear(2);
          bike2.changeCadence(40);
          bike2.speedUp(10);
          bike2.changeGear(3);
          bike2.printStates();
      }
  
  }
  </code></pre>
  
  <p>Then I want a new class called 'MountainBike' to inherit from the class 'Bicycle', and I wrote the following new code:</p>
  
  <pre><code>package mountainbike;
  
  public class MountainBike extends Bicycle {
  
      public static void main(String[] args) {
          // TODO code application logic here
      }
  
  }
  </code></pre>
  
  <p>But here I get an error indication on the line of <code>public class MountainBike extends Bicycle {</code> saying <code>cannot find symbol class Bicycle</code>.</p>
  
  <p>I suppose I have to put an "import" somewhere, but what should I import exactly?</p>