6.34 使用接口模仿枚举类继承
枚举类不能继承其它类,但是枚举类可以继承接口,如下接口:
private static <T extends Enum<T> & Operation> void test(Class<T> opSet,double x, double y) {for (Operation op : opSet.getEnumConstants())System.out.printf("%f %s %f = %f%n", x, op, y, op.apply(x, y));}private static void test(Collection<? extends Operation> opSet, double x,double y) {for (Operation op : opSet)System.out.printf("%f %s %f = %f%n", x, op, y, op.apply(x, y));}?
?
?
?