Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:49:42+00:00 2026-06-11T22:49:42+00:00

I’m trying to delete all the duplicate points within two array lists. Each list

  • 0

I’m trying to delete all the duplicate points within two array lists. Each list is created by finding which country links to which country, if they link then it creates a new point in both arrays at the same time.

The idea is so that I can loop though the size of both arrays (Or size of one) and draw lines between the points.

Problem at the moment is that it’s not deleting the points or it deletes them all.

I have the following Arrays

//Different values of course.
Array1 = [Point[1,5]],[Point[1,5]],[Point[1,5]][Point[1,5]]
Array2 = [Point[1,5]],[Point[1,5]],[Point[1,5]][Point[1,5]]

Here’s the code that deletes the duplicate arrays out:

private ArrayList<ArrayList<Point>> checkDuplicatePoints(ArrayList<Point> Array1, ArrayList<Point> Array2)
{
    for(int index1 = 0; index1 < Array1.size(); index1++)
    {
        for(int index2 = 0; index2 < Array2.size(); index2++)
        {
            //So not the same position in the list.
            if(index1 != index2)
            {
                if(
                    Array1.get(index1).x == Array2.get(index2).x &&
                    Array1.get(index1).y == Array2.get(index2).y
                )
                {
                    Array1.remove(index1);
                    Array2.remove(index2);
                    checkDuplicatePoints(Array1, Array2);
                }
            }
        }
    }

    ArrayList<ArrayList<Point>> n2DPointArray = new ArrayList<ArrayList<Point>>();

    n2DPointArray.add(Array1);
    n2DPointArray.add(Array2);

    return n2DPointArray;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:49:43+00:00Added an answer on June 11, 2026 at 10:49 pm

    As far as i underStand your problem may be you should look into these code and example

    public class test {
    public static void main(String ap[])
    {
    
        List<Point> mList1 =new ArrayList<Point>();
        List<Point> mList2 =new ArrayList<Point>();
        Point mPoint1 = new Point(1, 2);
        Point mPoint2 = new Point(2, 3);
    
        for (int i=0;i<3;i++){
            mList1.add(mPoint1);
            mList1.add(mPoint2);
        }
        Point mPoint3 = new Point(1, 2);
        Point mPoint4 = new Point(3, 4);
    
        for (int i=0;i<2;i++){
            mList2.add(mPoint3);
            mList2.add(mPoint4);
        }
    
        System.out.println(mList1);
        //System.out.println(mList2);
        new test().removingDuplicatesQID(mList1, mList2);
        System.out.println(mList1);
    }
    public void removingDuplicatesQID(List<Point> list1,List <Point> list2)
    {
        Set<Point> uniqueEntries = new HashSet<Point>();
        for (Iterator iter = list1.iterator(); iter.hasNext();)
        {
            Point element = (Point) iter.next();
            if (!uniqueEntries.add(element))
                /* if current element is a duplicate, remove it */
                iter.remove();
        }
        uniqueEntries.clear();
    }
    }
    

    OUTPUT

        System.out.println(mList1);
    

    [java.awt.Point[x=1,y=2], java.awt.Point[x=2,y=3], java.awt.Point[x=1,y=2], java.awt.Point[x=2,y=3], java.awt.Point[x=1,y=2], java.awt.Point[x=2,y=3]]

    //after removing duplicate from arrayList1

            System.out.println(mList1);
    

    [java.awt.Point[x=1,y=2], java.awt.Point[x=2,y=3]]

    I hope this could help you or ..else be more specific to your problem and result you need out of your array list

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to select an H1 element which is the second-child in its group
I have a text area in my form which accepts all possible characters from
I have an array which has BIG numbers and small numbers in it. I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.