策略模式的实现源代码实例

时间:2014-06-01 09:59:36
【文件属性】:
文件名称:策略模式的实现源代码实例
文件大小:6KB
文件格式:RAR
更新时间:2014-06-01 09:59:36
策略模式 源码实现 Java API中的Collections有一个sort方法, sort(List list, Comparator c) 其中Comparator是比较算子。通过实现Comparator接口可以定义满足个各种需要的排序方式。 这个例子是通过一个Student的ArrayList,然后分别输出按照学生姓名字典排序结果和按照分数由高到低的排序结果。 是策略模式运用的一个很好实例!
【文件预览】:
策略模式应用实例
----.project(394B)
----bin()
--------IntComparator.class(770B)
--------AlphaComparator.class(751B)
--------Main.class(2KB)
--------Student.class(561B)
----.settings()
--------org.eclipse.jdt.core.prefs(629B)
----src()
--------IntComparator.java(316B)
--------Main.java(1014B)
--------Student.java(272B)
--------AlphaComparator.java(241B)
----.classpath(301B)

网友评论