如果我有一个枚举对象,它将被视为原始对象还是引用?
这是参考类型。Java原语是boolean byte short char int long float double。
boolean byte short char int long float double
您可以通过调用ordinal(),获取枚举常量的值,该iterator值由EnumSet和EnumMap使用,并且“以其自然顺序遍历元素(声明枚举常量的顺序)”
ordinal()
iterator
您甚至可以将自己的成员添加到枚举类,如下所示:
public enum Operation { PLUS { double eval(double x, double y) { return x + y; } }, MINUS { double eval(double x, double y) { return x - y; } }, TIMES { double eval(double x, double y) { return x * y; } }, DIVIDE { double eval(double x, double y) { return x / y; } }; // Do arithmetic op represented by this constant abstract double eval(double x, double y); } //Elsewhere: Operation op = Operation.PLUS; double two = op.eval(1, 1);