This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

List Duplicated

 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to remove duplicates from arraylist without using set or api?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With a lot of hard work. Think about how you would do it, and tell us your ideas.
 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont want to use sets. but using api like remove method is fine. am still trying. will post if i get succeed.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good luck with it. If you get part of it right, post what you have and we'll be happy to look at it.
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shiaber,

I'm curious about why you don't want to use a Set. It seems like the easiest way to go about removing duplicates.

John.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People are sometimes given assignments or exercises which tell them to avoid the easy or obvious way to do things
 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt want to use sets as i had to do an additional thing while removing duplicates and that cant be done if i remove duplicates using sets. i found some algorithm from net to remove duplicates and enhanced it in the way i wanted.

thanks,
 
Campbell Ritchie
Sheriff
Pie
Posts: 49789
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done

Please tell us briefly how you did it, then others can learn from your experience.
 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried in a different method by removing duplicates in the orig. list. It didnt work. I got the below algorithm from net and changed to my need.

>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic