Good afternoon.
I'm learning how to use enum
types in Java and experiencing some problems.
First, I created my enum
as follows:
public enum enumUpdateAction {
NEW(0), CHANGE(1), DELETE(2), DELETE_THRU(3), DELETE_FROM(4);
public int codigo;
enumUpdateAction(int codigo) {
this.codigo = codigo;
}
public int getCodigo() {
return this.codigo;
}
}
Now, I need to use this enum inside a Switch, in another class:
public static LinkedList<LinkedList<Eventos>> Working(enum_type tipo, enum_updateAction updateAction) {
switch (Eventos.get(0).getUpdateaction()) {
case enum_updateAction.NEW://enum_updateAction.NEW: // 0 = new
ArrayEventos.add(InserirOrdenado(ArrayEventos, Ordem), Ordem);
break;
}
}
The Eventos.get(0).getUpdateaction()
returns a int
. I could use numbers 0 to 2 in cases, but since I know each number represents BID
, OFFER
or TRADE
, I'm trying to use those words directly in switch
, with the help of enum
. However, I get " enum_updateAction.NEW can not be converted to int ". Can anyone tell me how I get the value number of NEW
of enum
, and not the word NEW
itself?