I would like to reference an array with an enum type. This is a pretty standard thing in C++ (my origin), however I'm unsure if this is possible/desirable in Java.
For example, I would like to have an enum such as:
public enum Resource {
COAL,
IRON
}
Then later I would like to reference like this:
Amount[COAL] // The amount of coal
Price[IRON] // The price of iron
I don't want to make Amount
and Price
fields of Resource
as I would like a list of objects (orders for resources) grouped by the resource type. Manually assigning an int to each type of Resource
is no better than public static int final BLAH
I feel, nothing gained.
In essence, I'm looking for the enum of C++ which tags things. I realise that this could be the 'wrong' way of doing things in Java, so feel free to point me in the direction of the correct Java ethos.