Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java enum

package org.o7planning.tutorial.javaenum;

public enum Currency {
  VND, USD, EURO ;

  @Override
  public String toString() {
      if (this == VND) {
          return "Dong";
      } else if (this == USD) {
          return "Dola";
      }
      return super.toString();
  }
  public static void main(String[] args) {
      Currency money = Currency.USD;
      System.out.println("Money " + money);
      System.out.println("Money " + money.toString());
      System.out.println("VND " + Currency.VND);
      System.out.println("EURO " + Currency.EURO);
  }
}
Source by openplanning.net #
 
PREVIOUS NEXT
Tagged: #java #enum
ADD COMMENT
Topic
Name
6+1 =