List 通过 Collections.binarySearch 进行记录筛选
1.
Collections.sort(list, new Comparator<TreeDto>() { @Override public int compare(TreeDto a2, TreeDto b2) { return a2.getId().compareTo(b2.getId()); } }); Collections.binarySearch(list,new TreeDto(null,null,Integer.valueOf(paramId),null,null,null,null,null), new Comparator<TreeDto>() { @Override public int compare(TreeDto o1, TreeDto o2) { // TODO Auto-generated method stub if (o1.getPid() != null && o2.getPid() != null) { return o1.getPid().compareTo(o2.getPid()); }else if (o1.getPid() == null && o2.getPid() == null) { return 0; } return -1; } });