ArrayList<String> ArrayTemp = new ArrayList<>();
for(int x=0;x<ABC.size();x++){
for(int y=0;y<ArrayTemp.size()+1;y++){
if(!ABC.get(x).equals(ArrayTemp.get(y))){
ArrayTemp.add(ABC.get(x));
CountTemp.add(Count[x]);
}
}
}
Above shown my code, I am going to compare each element for the array ABC to remove duplicate of the element. Meanwhile I need the Count value also. Basically the contain and result will look like: Contain:
ABC Count
aaa 9
aaa 9
aab 8
aba 8
aaa 9
aab 8
The result i need is:
ArrayTemp CountTemp
aaa 9
aab 8
aba 8
Besides, i tried to use
Set ArrayTemp = new HashSet(); Set CountTemp = new HashSet();
This code seem does not synchronize my contain. Can anyone help me to solve this problem? Does't matter which the code is using, as long this can help me. Feel free to answer me and i will try each of the coding provided. Thank you very much.