一切都很好,但我想在LOCATIONNAME排序順序,locationMasterList有整數,字符串和Double對象.. 下面是我的代碼...名單按字母順序排序
List<LocationMaster> locationMasterList = locationMasterService.findByProperty("locationId", locationId);
for (int n = 0; n < locationMasterList.size(); n++) {
YearwiseBudget yearwiseBudget1 = new YearwiseBudget();
String locationName = locationMasterList.get(n).getLocationNameE();
Integer distId = locationMasterList.get(n).getLocationId();
yearwiseBudget1.setRecordId(recordId.longValue());
yearwiseBudget1.setAllocation(allocation);
yearwiseBudget1.setExpenditure(expenditure);
yearwiseBudget1.setLocationName(locationName);
yearwiseBudget1.setAllocGen(allocGen);
yearwiseBudget1.setAllocSC(allocSC);
yearwiseBudget1.setAllocST(allocST);
yearwiseBudget1.setExpGen(expGen);
yearwiseBudget1.setExpSC(expSC);
yearwiseBudget1.setExpST(expST);
yearwiseBudget1.setDistrictId(distId);
YearwiseBudgetList2.add(yearwiseBudget1);
}
你可以爲'POJO'實現'Comparable'接口,然後你可以使用'Collections.sort(YourPojo)'。 – AknKplnoglu 2014-09-22 10:06:08