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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:21:06+00:00 2026-06-07T11:21:06+00:00

Initially i will be selecting a list of student names in a page and

  • 0

Initially i will be selecting a list of student names in a page and submit for getting the address details.StudentNames will be stored in the studentDetailMapList.While looping through the list , i will compare the student names with the AddressDetailsMap to retrieve the addressDetails.But when there are students with same names , the first iteration returns the exact address but when the second iteration happens , it again returns the 1st student address instead of the second student address.It is getting the duplicate values

for (i=studentDetailMapList.values().iterator;i.hasNext();)
{
  detailMap = (Map)i.Next();
  sDetails =  (StudentDetails)detailMap.get("Student");
  student = sDetails.getRollNo();
  StudentAddressDetails studentAddressDetails  = getDetailswithAddress(AddressDetailsMap,sDetails);
}

private StudentAddressDetails getDetailswithAddress(Map AddressDetailsMap,sDetails student)
{
      StudentAddressDetails addDetails = null;
        try{
        for(Iterator itr = AddressDetailsMap.values().iterator();itr.hasNext();){
                addDetails = (StudentAddressDetails )itr.next();
                if( (addDetails != null) && (addDetails.getStudentID().equals(student.getId()))){
                    return addDetails;
                }
        }
        }catch(Throwable t){
            return null;
        }
        return null;
    }

Is there a way to avoid the duplicate while comparing with the map?
Thanks a lot.

  • 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-07T11:21:09+00:00Added an answer on June 7, 2026 at 11:21 am

    The problem you are having is that you are using the the map data structure wrong.

    A map is an object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

    You can not have multiple addresses for the same name, you should use other property for the map, maybe a Student ID, even the list’s index should work in this case.

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

Sidebar

Related Questions

We have a new filestream database that will be initially loaded with 65GB data,
Similar to Android unlock pattern where in, initially all the circular cells will be
I have a list of categories that are stored as Strings in an ArrayAdapter
I am trying to create a Javascript application which displays initially Countries information, Selecting
I had initially built a DatePicker. A Calendar Dialog will open next to a
Hi all i am having a list box on my Form which will display
My initial task was to find a segmenter for Windows that will split a
I am doing some initial testing for a Rails app which will be deployed
Initially I thought it was a CSS issue but I built a small sample
Initially I used DIN font for text. Later I come to know it is

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.