对象排序

根据名称首字母排序:

  实现 Comparable<Student> 接口

  重写compareTo(Student stu)方法

  Collator cmp = Collator.getInstance(java.util.Locale.CHINA);

  if (this.studentName.equals(stu.getStudentName)) {

   return cmp.compare(studentName, stu.getStudentName)

  }

 

posted @ 2017-06-29 09:36  馳騁衿琾  阅读(109)  评论(0编辑  收藏  举报