Back
use the enum to make a few constants:
enum ids {OPEN, CLOSE};
the OPEN value is zero, but I want it as 100. Is it possible?
If you use very big enum types then, following can be useful;
public enum deneme { UPDATE, UPDATE_FAILED; private static Map<Integer, deneme> ss = new TreeMap<Integer,deneme>(); private static final int START_VALUE = 100; private int value; static { for(int i=0;i<values().length;i++) { values()[i].value = START_VALUE + i; ss.put(values()[i].value, values()[i]); } } public static deneme fromInt(int i) { return ss.get(i); } public int value() { return value; }}
public enum deneme {
UPDATE, UPDATE_FAILED;
private static Map<Integer, deneme> ss = new TreeMap<Integer,deneme>();
private static final int START_VALUE = 100;
private int value;
static {
for(int i=0;i<values().length;i++)
{
values()[i].value = START_VALUE + i;
ss.put(values()[i].value, values()[i]);
}
public static deneme fromInt(int i) {
return ss.get(i);
public int value() {
return value;
31k questions
32.8k answers
501 comments
693 users