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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:39:08+00:00 2026-05-25T17:39:08+00:00

Hi all I’m using a HashMap to hold one of my object with a

  • 0

Hi all I’m using a HashMap to hold one of my object with a string key. when I put an object with a key it has no problem, when I put my second object I got my object added but can’t get it with its key. Somewhat it goes to somewhere that is “next”. I took a screenshot from debug mode (eclipse), below

enter image description here

although size shows 2, I can’t see my second item in hashmap, but in other hashmap’s next node.

To note something I use my key like in a form “name.tag”, tag and name in same time can never be the same, but “tag” can be the same. does hashmap has something to do with dot operator when evaluating keys? I hope I could write clearly,

Thanks in advance

Edit:
Here is a piece of code I use to create my hashmap

        private HashMap<String,ParameterItem> parseParametersNode(DataModel parent,Element element){
        NodeList parameterChilds=element.getChildNodes();//gep element parameters
        HashMap<String, ParameterItem> parameterItems=new HashMap<String, ParameterItem>();
        for(int i=0;i<parameterChilds.getLength();i++){
            if(parameterChilds.item(i).getNodeType()==Node.ELEMENT_NODE){
                Element el=(Element) parameterChilds.item(i);
                NamedNodeMap atts=el.getAttributes();
                ParameterItem item=new ParameterItem();

                for(int j=0;j<atts.getLength();j++){
                    Attr attribute=(Attr) atts.item(j);
                    String attributeValue=attribute.getValue();
                    String attributeName=attribute.getName();
                    item.setParsedProperty(attributeName, attributeValue);
            } /*check  attributes later*/
                //finish loop and insert paramitem to params
                String key="key"+i;
                if(item.getTag()!=null && item.getName()!=null)
                    key=item.getName()+"."+item.getTag();
                parameterItems.put(key, item);
//              testParam=item;
//              parameterItems.put(key, testParam);
                }
        }
        return parameterItems;

    }
  • 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-25T17:39:08+00:00Added an answer on May 25, 2026 at 5:39 pm

    There is not really a problem here: you have a hash collision. That is, both of your keys have been placed in the same hash bucket. It appears you have only four buckets (odd, I thought the initial default was 10 or 16), so the chance of that with random data is 25 percent. Your size incremented just fine. The next is the internal implementation’s way of pointing to the next element in the same bucket. If the number of elements in each buckets gets too big, Java will internally rehash into more buckets.

    I do not see why you need a HashTable here since you are numbering your keys consecutively (you could use an ArrayList), but maybe this is just starter code and your real use case is different.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
All -- I have these two methods in one of my classes: public static
all. We're trying to get some intersect collisions working, but the problem experience is
All of a sudden, Facebook sharing has stopped working on my site. It's been
All, I am building a small site using PHP. In the site, I receive
All, I'm using wordpress with this and for some reason the eventDrop stopped working.
All, I'm using Facebook Connect (JS SDK) to authenticate a user to my site.
All I want is to make a simple user password login. I have put
All the articles I've found via google are either obsolete or contradict one another.
All my classes are derived from this T class: public abstract class Problem<T, TResult>

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.