Answers for "how to create enum with value code in java"

0

enum with numbers java

public enum EXIT_CODE {
    A(104), B(203);

    private int numVal;

    EXIT_CODE(int numVal) {
        this.numVal = numVal;
    }

    public int getNumVal() {
        return numVal;
    }
}
Posted by: Guest on June-18-2020
0

enums with values in java

public enum Element {
    H("Hydrogen"),
    HE("Helium"),
    // ...
    NE("Neon");

    public final String label;

    private Element(String label) {
        this.label = label;
    }
}
Posted by: Guest on July-25-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language