Java - Allgemein

Enumeration (enum)

Code-Beispiel:

public enum Example { 
   EINS, ZWEI, DREI, VIER, FUENF, SECHS 
}


Einfache Verwendung:

for (Example zahl : Example.values())
   System.out.println(zahl);




Enumaration mit Parameter

public enum Month {
  JAN(31), 
  FEB(28),
  MAR(31), 
  APR(30), 
  MAY(31), 
  JUN(30),
  JUL(31), 
  AUG(31), 
  SEP(30), 
  OCT(31), 
  NOV(30), 
  DEC(31);
 
  private int days;
 
  Month(int days) {
    this.days = days;
  }
 
  public int getDays() {
    return days;
  }
}


Einfache Verwendung:

for (Month month : Month.values())
   System.out.println(month.getDays());



Eigene Werkzeuge
Werkzeuge

gratis Counter by GOWEB
seit 9.10.2007