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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:25:05+00:00 2026-05-28T02:25:05+00:00

There are two arraylists: ArrayList<Integer[]> arr1 = new ArrayList<Integer[]>(); ArrayList<Integer[]> arr2 = new ArrayList<Integer[]>();

  • 0

There are two arraylists:

ArrayList<Integer[]> arr1 = new ArrayList<Integer[]>();
ArrayList<Integer[]> arr2 = new ArrayList<Integer[]>();
arr1.add(new Integer[]{1,2,3});
arr1.add(new Integer[]{1,2,2});
arr1.add(new Integer[]{1,2,3});
arr1.add(new Integer[]{1,1,1});
arr1.add(new Integer[]{1,1,1});

arr2.add(new Integer[]{1,2,3});
arr2.add(new Integer[]{1,2,2});

How to delete rows from arr1 that appear in arr2 and that are non-unique in arr1? E.g. in this example I would need to delete only {1,2,3}, because it appears more than once in arr1. The only solution that comes to my mind is to use 4 FOR loops, but it seems to be very inefficient solution.

Edit#1
Resulting arr1: {1,2,3},{1,2,2},{1,1,1},{1,1,1}

  • 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-28T02:25:05+00:00Added an answer on May 28, 2026 at 2:25 am

    In case if you can use a List instead of array then you could do something as follows:

    List<List<Integer>> arr1 = new ArrayList<List<Integer>>();        
    List<List<Integer>> arr2 = new ArrayList<List<Integer>>();
    
    arr1.add(Arrays.asList(new Integer[]{1, 2, 3}));
    arr1.add(Arrays.asList(new Integer[]{1, 2, 3}));
    arr1.add(Arrays.asList(new Integer[]{1, 2, 2}));
    arr1.add(Arrays.asList(new Integer[]{1, 2, 3}));
    arr1.add(Arrays.asList(new Integer[]{1, 1, 1}));
    arr1.add(Arrays.asList(new Integer[]{1, 1, 1}));
    
    arr2.add(Arrays.asList(new Integer[]{1, 2, 3}));
    arr2.add(Arrays.asList(new Integer[]{1, 2, 2}));
    
    System.out.println(arr1);
    System.out.println(arr2);
    
    Set<List<Integer>> set1 = new HashSet<List<Integer>>();        
    Iterator<List<Integer>> it = arr1.iterator(); 
    
    while(it.hasNext()) {
        List<Integer> curr = it.next();
        if(!set1.add(curr) && arr2.contains(curr)) {
            it.remove();
        }
    }
    
    System.out.println(arr1);
    

    Output:

    [[1, 2, 3], [1, 2, 3], [1, 2, 2], [1, 2, 3], [1, 1, 1], [1, 1, 1]]
    [[1, 2, 3], [1, 2, 2]]
    [[1, 2, 3], [1, 2, 2], [1, 1, 1], [1, 1, 1]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is the following. There are multiple rows that have non-unique identifiers: id
Hey, I have this code here: ArrayList arrayList = new ArrayList(); arrayList.add(one); arrayList.add(two); arrayList.add(three);
Say I have two Collections : Collection< Integer > foo = new ArrayList< Integer
There are two sub-problems. 1- Comparing two huge arraylists 2- Sorting elements of arraylist
I have a class that contains two arraylists which I'm trying to store objects
Box buttonBox = new Box(BoxLayout.Y_AXIS); Name1 name2 = new Name1(); there are two Name1s
I have two ArrayList<Integer> as follows: original: 12, 16, 17, 19, 101 selected: 16,
In Eclipse there are two places that I've attempted to configure so that Fiddler
Consider that there are two entities, Department and Employee, where in one department there
I have one list: List<Object> myList = new ArrayList<Object>(); To get from this list

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.