以下两个方法传入参数类型不一样,但是处理逻辑是一致的,要怎么才能消除重复代码privatevoidsetStudentExamRank(Listlist){Listtemp=Lists.newArrayListWithCapacity(list.size());temp.addAll(list);temp.sort(Comparator.comparingInt(StudentExam::getScore));StudentExame;for(inti=0;i<temp.size();i++){e=temp.get(i);e.setRank(e.getScore()>0?i+1:0);}}privatevoidsetStudentClassesTestRank(Listlist){Listtemp=Lists.newArrayListWithCapacity(list.size());temp.addAll(list);temp.sort(Comparator.comparingInt(StudentClassesTest::getScore));StudentClassesTeste;for(inti=0;i<temp.size();i++){e=temp.get(i);e.setRank(e.getScore()>0?i+1:0);}}
MMTTMM
慕田峪7331174
相关分类