/***Extractuniqueelementsfromanarray**@paramarrinputarraywithredundantelements*/publicstaticvoidremoveRedundantElements(ArrayListarr){Collections.sort(arr);// remove the same elementsfor(intk=0;k<arr.size()-1;k++){Objecte=arr.get(k);// try to skip same elementintj=k+1;while(j<arr.size()){if(arr.get(j).equals(e)){arr.remove(j);j--;}j++;}}}
Last edit: Duy Dinh 2013-06-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Last edit: Duy Dinh 2013-06-13
A better way to get unique elements from an array