Iterate through enums in Java using for-each?
public enum Wochentage { MONTAG(100), DIENSTAG(200), MITTWOCH(300); private final int value; Wochentage(int i) { this.value = i; } public int getValue() { return value; } }
I now want to output the values โโof the enum in the main using for-each:
for (Wochentage w = Wochentage.values()) { System.out.print(w + " "); }
I'm getting an error with weekdays.values(). I honestly don't understand why a semicolon is missing.
What you mean looks more like for each, doesn't know how it is in Java meanwhile, but formally I think your syntax is an incomplete for loop.
Like me
No, there's a = instead of the double point…
for-each loops need a double point.
Check it out
Nice, nice my name leaked haha
Hi Flo
yes, fits ๐๐ผ
I've got the exam coming. If I have any questions, I'll report.
Sure. ๐
Thank you.