In Java you can't specify the ordinal values explicitly at all. They always autoincrement, from 0, with no control over it.
If you want other custom values, you need to put them in constructor calls and store them yourself. You can get autoincrement, but it's icky as heck:
import java.util.EnumSet;
// Please don't ever use this code. It's here so you can point and laugh.
enum Foo
{
A(10), B, C, D(5000), E, Fish;
private static int nextValue;
private int value;
private Foo()
{
this(Counter.nextValue);
}
private Foo(int value)
{
this.value = value;
Counter.nextValue = value + 1;
}
public int getValue()
{
return value;
}
private static class Counter
{
private static int nextValue = 0;
}
}
public class Test
{
public static void main(String[] args)
{
for (Foo foo : EnumSet.allOf(Foo.class))
{
System.out.println(foo.name() + " " +
foo.ordinal() + " " +
foo.getValue());
}
}
}
Note the need for the nested class, because you can't access static fields within an enum constructor. Ick, ick, ick. Please don't do this.