Using Enum as Array Index
807580Feb 11 2009 — edited Nov 9 2009Hi Experts,
Can you please suggest whether it 's possible to use a Enum as an array index in java? In C++, I can define a enum and use the enum as the array index. But, for some reason, I 've not been able to do so in Java. Can anyone please help me in achieving this.
Enum Index{indexOne, index2 ....};
Index ind;
and I should be able to use this for any array as an index:
String s = stringArray[ind.indexOne];
Is this possible in java? Please suggest.
Thanks,
Ganapathi