java - How to remove duplicate entries in an ArrayList -


I have an ArrayList & lt; Integer & gt; that pulls from my database wants to know how it is possible to loop through them, so I can remove the duplicate.
Thanks in advance,
Dean

If there is no duplicate then Use set instead of the list .

You set either where you are currently using your list , or you set to remove duplicate elements .

  set & lt; Integer & gt; Year = new hashset & lt; Integer & gt; (MyOldArrayList);  

Or you can change from one store to another, I'm not sure what the effect of the display is:

  ArrayList & lt; Integer & gt; Year = // dominated by years of database = new Arrives & Lt; Integer & gt; (New hashaseet and lt; integer & gt; (years));  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -