Answers for "enumeration java"

10

java enum

public class DaysOfTheWeek {

    public enum Days {m, t, w, r, f, sat, s};
  	    public static void main(String[] args) {
          Days d = Days.t; 
          System.out.println(d);
          //the output would be t
        }
}
Posted by: Guest on April-30-2020
0

enumeration java

public enum Feu {

    VERT(0), ORANGE(1), ROUGE(2);


    private int value;

    private Feu( int value ) {
        this.value = value;
    }

    public int toInt() {
        return value;   
    }
    
    public static Feu fromInt( int value ) {
        switch( value ) {
            case 0: return VERT;
            case 1: return ORANGE;
            default: return ROUGE;
        }
    }
    
}
Posted by: Guest on August-15-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language