-4

could you please tell me..

How to remove duplicates from list of objects by id In java

  • could you please show us your effort so far... – ΦXocę 웃 Пepeúpa ツ Nov 23 '17 at 06:02
  • Add Objects into `Set` which doesn't allow duplicates – Vipin CP Nov 23 '17 at 06:02
  • or dont put the duplicates in in the first place. – slipperyseal Nov 23 '17 at 06:04
  • How are we supposed to help if you don't show any effort in solving the problem? – RoadRunner Nov 23 '17 at 06:09
  • Welcome to Stackoverflow, please read [How To Ask](https://stackoverflow.com/help/how-to-ask). Pay special attention to [How To Create MCVE](https://stackoverflow.com/help/mcve). The more effort you'll put into posting a good question: one which is easy to read, understand and which is [on topic](https://stackoverflow.com/help/on-topic) - the chances are higher that it will attract the relevant people and you'll get help even faster. Good luck! – Nir Alfasi Nov 23 '17 at 06:16
  • Hi RaodRunner, i am doing like this... .... ArrayList list = new ArrayList(); list .add("abc"); list .add('a'); list .add('b'); list .add('a'); list .add("abc"); list .add('c'); list .add(10); list .add("abc"); list .add(10); for(int i=0;i – Piyush shukla Nov 23 '17 at 06:29

1 Answers1

0
  for(int id=0;i<list.size();i++)
  {
   object = list.get(i);

     for(int j; j<list.size();j++)
     {

       object1 = list.get(j);

          if(object == object1 && id != j){
          list.remove(j);
      }
   }


}
Mr. Sanjay
  • 34
  • 2