Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Does HashpMap automatically expand?

Thread view: 
www - 04 Jun 2007 14:21 GMT
Hi,

I am using my office-mate's class. My class is subclass of hers. Her
class has a private HashMap.

public abstract Parent   //her class
{
    private Map<String, Object> _map;
   
    public Parent()
    {
        _map = new HashMap(10);     //only with size of 10 !!!
    }

    public void insertState(String tag, double value) {
        _map.put(tag, new Double(value));
    }
    ...
}

public Sub extends Parent //my class
{
    public Sub()
    {
        insertState("ATag", 1.2);
        insertState("BTag", 1.6);
        insertState("CTag", 1.8);
        insertState("DTag", 2.5);
        ...                //I inserted 15 times with different tags and values. My
program works correctly. Every value can be successfully retrieved.

    }

    ...
}

How to explain why I can insert more than 10 tags-values into map and my
program works correctly? Is this possible? Or my program actually does
Not run correctly, just my testing is not rigorous enough?

Thank you.
Daniel Dyer - 04 Jun 2007 14:27 GMT
> Hi,
>
> I am using my office-mate's class. My class is subclass of hers. Her  
> class has a private HashMap.

...

> How to explain why I can insert more than 10 tags-values into map and my  
> program works correctly? Is this possible? Or my program actually does  
> Not run correctly, just my testing is not rigorous enough?

RTFM: http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html

Dan.

Signature

Daniel Dyer
http://www.uncommons.org

Twisted - 04 Jun 2007 14:41 GMT
To answer the question in the subject, yes.

Note that my reply is politer than the other one.
Lew - 04 Jun 2007 15:32 GMT
> To answer the question in the subject, yes.
>
> Note that my reply is politer than the other one.

Daniel's answer was useful, though - he provided the link to explain in more
detail in case the OP needed more depth.  Programming knowledge is ideally
like the proverbial tip of the iceberg - you only show the top 10%.  Daniel
was helping the OP know where to find the other 90% that makes that possible.

Signature

Lew

www - 04 Jun 2007 15:39 GMT
>> To answer the question in the subject, yes.
>>
[quoted text clipped - 5 lines]
> 10%.  Daniel was helping the OP know where to find the other 90% that
> makes that possible.

It is strange. I don't see any posting by Daniel. I only see Twisted and
Lew's. So I have no idea what Lew and Twisted are talking about.
Lew - 04 Jun 2007 15:57 GMT
> It is strange. I don't see any posting by Daniel. I only see Twisted and
> Lew's. So I have no idea what Lew and Twisted are talking about.

Here ya go:

>>> Hi,
>>>
[quoted text clipped - 13 lines]
>> --Daniel Dyer
>> http://www.uncommons.org
Daniel Dyer - 04 Jun 2007 18:54 GMT
> To answer the question in the subject, yes.
>
> Note that my reply is politer than the other one.

Indeed, but not as helpful ;)

I like to interpret RTFM as "Read The Fine Manual", rather than the usual,  
coarser interpretation.  No offence intended to the OP, but it's probably  
best to check the docs first (or even ask the co-worker who's code you  
were having problems with).

Dan.

Signature

Daniel Dyer
http//www.uncommons.org



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.