title: Why is a template method marked final?
body: <p>In template method pattern, there is a method marked <code>final</code>, but I cannot understand the meaning of having this method. Please help me out. In another word, in class PackageA, one can implement the algorithm for each abstract method as needed. And the client can call method in PackageA with their own order. What is the function/ meaning to having this <code>public final void performTrip()</code>? Thank you very much.</p>
  
  <pre><code>public abstract class Trip {
      public final void performTrip() {
          doComingTransport();
          doDayA();
          doDayB();
          doDayC();
          doReturningTransport();
      }
  
      public abstract void doComingTransport();
  
      public abstract void doDayA();
  
      public abstract void doDayB();
  
      public abstract void doDayC();
  
      public abstract void doReturningTransport();
  }
  
  public class PackageA extends Trip {
      @Override
      public void doComingTransport() {
          System.out.println("PKG A" + "coming");
      }
  
      @Override
      public void doDayA() {
          System.out.println("PKG A" + "A");
      }
  
      @Override
      public void doDayB() {
          System.out.println("PKG A" + "B");
      }
  
      @Override
      public void doDayC() {
          System.out.println("PKG A" + "C");
      }
  
      @Override
      public void doReturningTransport() {
          System.out.println("PKG A" + "Return");
      }
  
  }
  </code></pre>