第1个回答 2017-12-30
String[] str = {"aa","bb","cc","cc","bb"};
List<String> list = new ArrayList<>();
for (int i=0; i<str.length; i++) {
if(!list.contains(str[i])) {
list.add(str[i]);
}
}
System.out.println("去除重复后的list集合"+list);
for(int i=0;i<list.size();i++){
int count = -1;
for(int j=0; j<str.length; j++){
if(list.get(i).equals(str[j])){
count ++;
}
}
System.out.println(list.get(i)+"共重复了"+count+"次");
}