I’m not too familiar with Java and need some help with an enumeration lookup (I think that’s what it’s called?) I have many years of C experience, so I know what I’m trying to accomplish using C, but I don’t know the equivalent syntax or construct in Java.
I don’t have a C environment on this computer, so the syntax might be off, but this is what I’m trying to accomplish:
typedef enum regions_t {
REGION_CALIFORNIA,
REGION_HAWAII,
REGION_LOUISIANA,
REGION_NUM_REGIONS
} regions_t;
typedef struct regionData_t {
regions_t regionName;
char_t[50] url;
int32_t population;
} regionData_t;
regionData_t myRegions[REGION_NUM_REGIONS] {
{REGION_CALIFORNIA, "http://http://california.gov/", 10123321},
{REGION_HAWAII, "http://hawaii.gov", 5123321},
{REGION_LOUISIANA, "http://louisiana.gov/", 8123321}
}
This way, I can access, for example, the url data in this fashion, which is easy to read and easy to expand upon:
myRegions[REGION_HAWAII].url
How do I accomplish the same idea in Java?
Quick and dirty:
But you can also use the fact that enums in Java are normal classes, too.