Let's say I have an enum like so:
public enum Numbers {
ONE("Uno "),
TWO("Dos "),
THREE("Tres ");
}
private final String spanishName;
Numbers(String spanishName) {
this.spanishName = spanishName;
}
public String getSpanishName() {
return spanishName;
}
Now I have a method that outputs a given variable.
public void output(String value) {
printStream.print(value);
}
I want to use a for
loop to output all the values in the enum. Something along the lines of this:
for(/*each element in the enum*/) {
//output the corresponding spanish name
}
Ultimate I want the final output to be Uno Dos Tres
. How can I do this using enums and a for loop?