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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:41:44+00:00 2026-06-18T02:41:44+00:00

I think that I have a rather simple question, but I can’t figure out

  • 0

I think that I have a rather simple question, but I can’t figure out how i am supposed to do it. I have created one multiple arraylist, where I want to store some data from an array.
I want to check which entries are the same.

For example, if array[0] = array[5] = array[8] but array[1] is not equal to any entry, and array[2] = array[3]

I would like to have for the arraylist look like

array2[0] | array2[5] | array2[8]

array2[2] | array2[3]

 List<String> dup_non = new ArrayList<String>(), dn = new ArrayList <String>(); 

 for (int m = 0; m < array.length ; m++) 
    { 
        for(int o = m + 1; o < array.length; o++)         
        {   
              if (array[m].equals(array[o] && m!=o)){
                      dup_non.add(array2[m])
                      dn.add(array2[m],array2[o])
                               }
                          else { ....
                               } 
         }
     }

This code is what i was thinking more or less, since my array2 has unique elements, but it is not correct. It is correct, because array2 is not an array of integers.

If you have any idea, I would appreciate if you could share it.

Regards.

  • 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-18T02:41:45+00:00Added an answer on June 18, 2026 at 2:41 am
        Please check following program for your requirement
    
        I have created HashMap where Key as the your values that will duplicate and ArrayList as List of value duplicated  
    
    
        import java.util.Iterator;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Set;
    
    public class Dog {
    
    
        public static void main(String[] args) {
            Map<Integer,List<Integer>> hashMap=new HashMap<Integer,List<Integer>>();
             int array[]={1,1,1,2,2,2,4,3,3,3};
    
    
             for (int m = 0; m < array.length ; m++) {
                 System.out.print(array[m]);
                 List<Integer> dup=(List<Integer>)hashMap.get(array[m]);
                 if(dup==null){
    
                     dup=new ArrayList<Integer>();
                     hashMap.put(array[m],dup);
                     dup.add(array[m]);
    
                 }else{
                     dup.add(array[m]);
                 }
             }
    
             Set<Entry<Integer, List<Integer>>> keys = hashMap.entrySet();
             for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
                Entry<Integer, List<Integer>> entry = (Entry<Integer, List<Integer>>) iterator.next();
                List<Integer> arrayList = entry.getValue();
                if(arrayList.size()==1)
                    hashMap.put(entry.getKey(), null);
            }
    
    
             System.out.print(hashMap.get(1));
             System.out.print(hashMap.get(2));
             System.out.print(hashMap.get(3));
             System.out.print(hashMap.get(4));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think that's a rather simple Question but I don't get it the way
I think, the answer to my question is rather simple, but I just can't
Having an issue here that I have tried everything I can think of but
I have a rather simple question. I can't find an answer by searching though.
A rather simple question (I think), but I don't seem to see an answer
I have rather simple, I imagine, question about CRTP , but I cannot seem
O.K. I think that's an easy one! I have a ViewMasterPage with some links
I have an issue that (I think) might have to do with scope, but
I think this is a pretty simple question but I'm having trouble finding the
I think this question is probably fairly simple, but I've been searching around and

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.