首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

6.34 运用接口模仿枚举类继承

2013-08-13 
6.34 使用接口模仿枚举类继承枚举类不能继承其它类,但是枚举类可以继承接口,如下接口:private static T e

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));}

?

?

?

?

热点排行