0


How to get the value Apple if I pass A ...

public enum Enumtype {
  A("Apple"), B("Ball"), C("Cat");

  private String value;

  private Enumtype(String value) {
      this.value = value;
  }
}
Alexis C.
  • 91,686
  • 21
  • 171
  • 177
Beginner
  • 313
  • 1
  • 4
  • 15

1 Answers1

1

you need to add a getter in your enum :

public String getValue(){
    return this.value;
}
maximede
  • 1,763
  • 14
  • 24