Results 1 to 5 of 5
  1. #1
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Question What is the purpose of a HashMap?

    Okay, so I have been researching and I know what a hashMap does, that it stores data in a key, but what I am wondering is if it saves this data through application exit? Because I am writing a program that needs to remember information from use to use, and am wondering if this is the solution. If it is not, what is? I am having a hard time figuring it out.

    - Thanks for any input!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: What is the purpose of a HashMap?

    You can serialize the HashMap if its keys and values are Serializable; afterwards you can deserialize it again. (Read the API documentation for the Serializable interface). Your program has to do it, nothing happens automagically, i.e. serialize the HashMap before shutdown of your application and deserialize it at start up.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: What is the purpose of a HashMap?

    Oh, okay cool. Thanks! are there any other methods or is this really the only way? And if so, is this one the best choice of them all?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default Re: What is the purpose of a HashMap?

    There's lots of ways.
    Save to a database.
    Define your own file structure and save to that.
    But they all require you to write more code.

  5. #5
    Tombomb is offline Member
    Join Date
    Jan 2012
    Posts
    33
    Rep Power
    0

    Default Re: What is the purpose of a HashMap?

    Yeah, I had thought of defining my own file, but that was just a way of doing it I had thought up in my head. I would have no clue how to do that lol... Okay, well I'll give the hashmap a try and see what happens I guess! Cheers!

Similar Threads

  1. interface purpose?
    By frejon26 in forum New To Java
    Replies: 5
    Last Post: 06-27-2014, 09:41 AM
  2. Purpose of close() ?
    By fatabass in forum New To Java
    Replies: 4
    Last Post: 01-13-2012, 09:57 AM
  3. Purpose of abstract class
    By scott in forum Threads and Synchronization
    Replies: 5
    Last Post: 03-26-2010, 04:21 AM
  4. classes, true purpose of
    By mac in forum New To Java
    Replies: 1
    Last Post: 12-22-2009, 04:34 PM
  5. Replies: 7
    Last Post: 12-08-2009, 07:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •