While learning java i was trolling around SO and found question 116574. The accepted answer contained some java code that i did not understand.
EDIT: The code basically looks like this:
public enum SomeEnum {
FUN0 {
@Override
public void function() {
System.out.println("0 0 0 0 0");
}
},
FUN1 {
@Override
public void function() {
System.out.println("1 1 1 1 1");
}
};
public abstract void function();
public static void main(String[] args) throws Exception {
for (SomeEnum test : values()) {
test.function();
}
}
}
It looks advanced due to the organization of the code and i am so curious about it. If it is suitable for SO to ask this kind of question: Might someone be willing to explain a bit this code?
How does it come that an enum contains main? Should it not be a class? (Eclipse is not so happy about it, but runs the main function after asking to "Select Java Application") What is this construct with FUN0, FUN1?
A pointer to some tutorial text that explains this topic already make me happy.