Link to home
Start Free TrialLog in
Avatar of shragi
shragiFlag for India

asked on

Removed duplicates from list

Hi I wrote the below code to remove the duplicates from the arraylist.

      public static ArrayList<Integer> noDuplicates(ArrayList<Integer> inputList)
          {      
                   HashSet<Integer> inputListToSet = new HashSet<Integer>(inputList);
                   ArrayList<Integer> inputListWithoutDuplicates = new ArrayList<Integer>(inputListToSet);
                   return inputListWithoutDuplicates;
          }      

But i want to change this program to work for other numeric classes and generic objects?
what should i change ?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shragi

ASKER

thanks dpearson :)
Bear in mind your code will likely reorder the List too unless you use a LinkedHashSet