I\'d like to know if it is possible to define an enum with an Array as a constant; see the following code excerpt.
This does not compile with an illegal start of express
Yes, you'll just need to initialize them. For example,
NICKLE(5, new string[]{"five"})
For this use case, I would use a vararg approach instead:
public enum Currency {
PENNY(1, "one", "oneone"),
NICKLE(5, "five"),
DIME(10, "ten"),
QUARTER(25, "twentifive");
private int valueInteger;
private String[] valueString;
private Currency(int valueInteger, String... valueString) {
this.valueInteger = valueInteger;
this.valueString = valueString;
}
}