Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using Enum as Array Index

807580Feb 11 2009 — edited Nov 9 2009
Hi 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2009
Added on Feb 11 2009
6 comments
6,008 views