java_method_数据去重

时间:2023-01-14 05:57:36

/**
* 判断list本身是否有重复数据和标题
*
* @param list
* @return newList 返回没有重复数据的list
*/
public List<String[]> checkListRepeat(List<String[]> list, String title,
int length, int index) {
List<String[]> newList = new ArrayList<String[]>();
int num = list.size();

String[] infos = null;
for (int i = 0; i < num; i++) {
infos = list.get(i);
if (infos == null || infos.length < length) {
continue;
}

if (infos[index] == null || "".equals(infos[index])
|| title.equals(infos[0])) {
continue;
}

int rnum = newList.size();
boolean falg = true;
for (int j = 0; j < rnum; j++) {
if (infos[index].equals(newList.get(j)[index])) {
falg = false;
break;
}
}
if (falg) {
newList.add(infos);
}
}
return newList;
}