Thread: Enum Iteration
View Single Post
  #1 (permalink)  
Old 08-15-2007, 02:01 PM
A.Russell A.Russell is offline
Member
 
Join Date: Aug 2007
Posts: 1
A.Russell is on a distinguished road
Enum Iteration
How do you iterate through an enumeration in Java? I tried the way I would expect from working with C++:

Code:
for( int ix = 1; ix < MyEnum.LastEnum; ix++) { // Do something here }
I get the error "Cannot cast MyEnum to Int." Isn't an enumeration always a constant integral type? If not, how can I iterate through enumerations?
Reply With Quote
Sponsored Links