Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java enum

package org.o7planning.tutorial.javaenum;

public enum Color {
  RED("red") {
      @Override
      public String getHexCode() {
          return "#ff0000";
      }
  },
  GREEN("green") {
      @Override
      public String getHexCode() {
          return "#00ff00";
      }
  },
  BLUE("blue") {
      @Override
      public String getHexCode() {
          return "#0000ff";
      }
  };
  private String name;
  Color(String name) {
      this.name = name;
  }
  public String getName() {
      return name;
  } 
  public abstract String getHexCode();
}
Source by openplanning.net #
 
PREVIOUS NEXT
Tagged: #java #enum
ADD COMMENT
Topic
Name
3+6 =