M
MrChance
Gast
Code:
enum Enum {
ENUM1, ENUM2, ENUM3;
public static int a = 0;
public static int b;
Enum() {
Enum.a++;
Enum.b++;
}
}
public class Class {
public static int a = 0;
public static int b;
Class() {
Class.a++;
Class.b++;
}
public static void main(String[] args) {
new Class();
new Class();
new Class();
System.out.println("a=" + Class.a + " b=" + Class.b);
System.out.println("a=" + Enum.a + " b=" + Enum.b);
}
}
Raus kommt:
3 3
0 3
Wieso ???