I want to maintain a state table, where the states have been defined using a enum
private enum states {
contension_initiated, contension_failure, contension_success, reservation_success, reservation_completed, reservation_failure
}
and the state table is maintained using
HashMap<Integer, states> stateTable = new HashMap<Integer, states>();
depending on the conditions the values in the stateTable would vary/change
how can the same entry in the hashMap be modified without using the apache.commons libraries?
I have been doing this until now :
if(condition1)
stateTable.put(1,state.contension_initiated)
if(condition2)
stateTable.remove(1)
stateTable.put(1,contension_success)
HashMap will maintain only a single unique key. Therefore, if you try and “put” a key that already exists, it will replace the value associated with the key (rather then adding a new key)