Eliminate duplicates in List in Java

Source: Internet
Author: User

/**     *  eliminate duplicates      *  @param in list  srclist      *  @return      */    public  static list<gpsdata> dealrepeat (list<gpsdata> srclist) {         for (Int m =0; m<srclist.size ();  m++) {              string lat1=srclist.get (M). GetLat ();              string lng1 =srclist.get (M). GETLNG ();              boolean eq =  true;             while (eq) {                  int next  = m+1;                  if (next >  Srclist.size ()-1) break;                                    string lat2=srclist.get (Next). Getlat ();                  string lng2 =srclist.get (Next). GetLng ();                  if ( lat1.equals (LAT2)  && lng1.equals (lng2)  ) {                       srclist.remove (Next);                    } Else{                        eq= false;                    }              }        }        return  srclist;    }


This article is from the "Monkey Crazy" blog, make sure to keep this source http://1251769215.blog.51cto.com/11633863/1786989

Eliminate duplicates in List in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.