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 6915827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:31:26+00:00 2026-05-27T09:31:26+00:00

I am trying to create a method that removes duplicates from a 2d array.

  • 0

I am trying to create a method that removes duplicates from a 2d array. the outside array conains point indexes and the inner array contains their coordinates. It looks like i have to use an arraylist in order to remove elements without ending up with null values in the array. I would then like to convert the arraylist back into a 2D array in order to return it in the format i require. The problem is that the arraylsit contains an array of objects so i can’t cast it into an array designed for floats. what is the correct syntax for filtering the floats from my array list. my code follows:

public class rem_duplicates {
    public float [][] rem_geo_duplicates(float a[][]){

        ArrayList<float[]> al = new ArrayList<float[]>();
        float no_points = a.length;
        int count = 0;


        for (int i = 0; i < no_points-1; i++){
            if((a[i][0] == a[i+1][0])&&(a[i][1] == a[i+1][1])){
                    a[i] = null;
                    count ++;
            }

        for (int j = 0; j < no_points; j++){
            if (a[j] != null){
                al.add(a[j]);       
            }
        }

        //how do i get the arraylist 'al' into this array b[][]?
        float b[][] = new float [a.length-count][3];
        b = al.toArray();


        }

    }
    return b
}
  • 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-05-27T09:31:27+00:00Added an answer on May 27, 2026 at 9:31 am

    Try using the following:

    float b[][] = new float [a.length-count][3];
    b = al.toArray(b);
    

    This is the generic version of toArray() which in your case will return a float[][]. Keep in mind that float[] is an object, so there are no issues of boxing/unboxing here.

    I notice several basic issues with your code however – I recommend trying to compile it and resolving the errors.

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

Sidebar

Related Questions

Im trying to create a method that take 2 int array as the input
I'm trying to create a method that will sum two timeO objects and return
I am trying to create a method that accepts multiple types of controls -
I am trying to create a generic method that will read an attribute on
I am trying to create a unit test for a method that takes a
I'm trying to create a windowless Ogre application, but it seems that the method
I'm trying to create an application that will let me execute a method specified
I am trying to create a method that pretty much takes anything as a
I am trying to create a general method for disposing an object that implements
I'm trying to create a handy extension method to Action to basically run that

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.