title: Are enums less maintainable than public static final constants?
body: <p>I was recently discussing enums vs public static final constants with a friend. I told him that public static final constants are more maintainable than enums, sometimes faster (android developer docs confirm this), and more convenient as well. I also said that you lose functionality when using enums as well:</p>
  
  <ol>
  <li>You cannot extend an enum.</li>
  <li>You cannot instantiate an enum.</li>
  </ol>
  
  <p>He then said you shouldn't be using an enum if you need to instantiate or extend an enum. I then replied that's why we should just use constants because it is more maintainable; What if mid project we need to instantiate an enum or extend it? Then we would have to change everything. </p>
  
  <p>An example demonstrating enums vs constants I made to illustrate my point:</p>
  
  <pre><code>public enum WeekDay {
  /*
   * We will start at 1 for demonstration
   */
  SUNDAY("Sunday", 1), MONDAY("Monday", 2), TUESDAY("Tuesday", 3), WEDNESDAY(
          "Wednesday", 4), THURSDAY("Thursday", 5), FRIDAY("Friday", 6), SATURDAY(
          "Saturday", 7);
  /*
   * Notice we cannot do this...This is where enums fail.
   */
  // LUNES("lunes",1), MARTES("martes",2);
  
  private String dayName;
  private int dayIndex;
  
  private WeekDay(String dayName, int dayIndex) {
      this.dayName = dayName;
      this.dayIndex = dayIndex;
  }
  
  public String getDayName() {
      return dayName;
  }
  
  public void setDayName(String dayName) {
      this.dayName = dayName;
  }
  
  public int getDayIndex() {
      return dayIndex;
  }
  
  public void setDayIndex(int dayIndex) {
      this.dayIndex = dayIndex;
  }
  
  @Override
  public String toString() {
      return this.dayName + ":  " + this.dayIndex;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>What if we need Spanish week days as well? The enum falls short because you cannot extend it (you would have to do some copy and paste action).</p>
  
  <p>Contrast the enum with this:</p>
  
  <pre><code>public class WeekDayClass {
  
      private int dayIndex;
      private String dayName;
  
      public WeekDayClass(int dayIndex, String dayName) {
          super();
          this.dayIndex = dayIndex;
          this.dayName = dayName;
      }
  
      public int getDayIndex() {
          return dayIndex;
      }
  
      public void setDayIndex(int dayIndex) {
          this.dayIndex = dayIndex;
      }
  
      public String getDayName() {
          return dayName;
      }
  
      public void setDayName(String dayName) {
          this.dayName = dayName;
      }
  
      @Override
      public String toString() {
          return this.dayName + ":  " + this.dayIndex;
      }
  
      abstract static class Constants {
  
      }
  
  
      public static void main(String[] args) {
          WeekDayClass init = new WeekDayClass(10, "I can init new days here");
  
      }
  }
  </code></pre>
  
  <p>And then I can extend it and make AmericanWeekDays:</p>
  
  <pre><code>public class AmericanWeekDay extends WeekDayClass {
      public AmericanWeekDay(int dayIndex, String dayName) {
          super(dayIndex, dayName);
      }
  
      static class AmericanConstants extends Constants {
          public static final WeekDayClass SUNDAY = new WeekDayClass(1, "Sunday");
          public static final WeekDayClass MONDAY = new WeekDayClass(2, "Monday");
          /*
           * And so on...
           */
      }
  
  }
  </code></pre>
  
  <p>Or Spanish Week Days:</p>
  
  <pre><code> public class SpanishWeekDays extends WeekDayClass {
  
      public SpanishWeekDays(int dayIndex, String dayName) {
          super(dayIndex, dayName);
      }
  
      static class SpanishConstants extends Constants {
          public static final SpanishWeekDays LUNES = new SpanishWeekDays(2, "lunes");
          /*
           * And so on...
           */
      }
  
  }
  </code></pre>
  
  <p>Also to go even further:</p>
  
  <pre><code>public class WeekDayClass {
  
      private int dayIndex;
      private String dayName;
  
      public WeekDayClass(int dayIndex, String dayName) {
          super();
          this.dayIndex = dayIndex;
          this.dayName = dayName;
      }
  
      public int getDayIndex() {
          return dayIndex;
      }
  
      public void setDayIndex(int dayIndex) {
          this.dayIndex = dayIndex;
      }
  
      public String getDayName() {
          return dayName;
      }
  
      public void setDayName(String dayName) {
          this.dayName = dayName;
      }
  
      @Override
      public String toString() {
          return this.dayName + ":  " + this.dayIndex;
      }
  
      static class AmericanConstants {
          /*
           * Insert Constants Here
           */
  
      }
  
      static class SpanishConstants {
          /*
           * Insert Constants Here
           */
      }
  
  }
  </code></pre>
  
  <p>I understand with an enum you could perhaps make a workaround using data structures (Lists) so you accommodate this shortcoming but why bother? With using public static constants I gain inheritance from the base class, cleaner code, possibly shorter code, and easier maintainability.</p>
  
  <p>I also read that you can use enum's to better design "input parameters" but you could also do the same with the public static final constants as shown above.</p>
  
  <p>Enums have the advantage of being able to be used in switch statements and have the inherited enum methods like values(). These methods can also be replicated if needed in "public static final constant" classes. Aside from the switch I don't see any enum advantages.</p>
  
  <p>In conclusion, is an enum really better than public static final constants? If so, where did I go wrong? Is their something I am missing?</p>
  
  <p>EDIT:
  You cannot use generics in enums as well.</p>