Let's say I have an enum as such:
public enum Fruit {
APPLES("Apples"),
BANANAS("Bananas"),
PEAR("Pear"),
ORANGE("Oranges");
private final String string;
Fruit(String string) {
this.string = string;
}
}
What would be the best way to generate a String[] array containing the string values of the enum, i.e. "Apples", "Bananas, "Pear", "Oranges"
I can think of a few ways but they could get messy and I'm wondering if there is a direct way to get these values.