Results 1 to 4 of 4

Thread: Find in HashMap

  1. #1
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default Find in HashMap

    I made a dictionary (HaskMap).
    And I also have a: String info = "ACRFW"

    Now how do I look all those letters up in HashMap?
    I know how to store them, but how to look up one by one?

    Lund,

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

    Default

    Quote Originally Posted by Lund01 View Post
    I made a dictionary (HaskMap).
    And I also have a: String info = "ACRFW"

    Now how do I look all those letters up in HashMap?
    I know how to store them, but how to look up one by one?
    Something like this?

    Java Code:
    for (int i= 0; i < yourString.length(); i++ }
       String ss= yourString.substring(i, i+1);
       System.out.println(ss+": maps to: "+yourMap.get(ss));
    }
    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Lund01's Avatar
    Lund01 is offline Senior Member
    Join Date
    Sep 2010
    Location
    The Netherlands
    Posts
    149
    Rep Power
    0

    Default

    That was idd what I was lookig for.
    Thanks. :)

    I knew the answer would be short, but I realy couldn't find it.

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

    Default

    Quote Originally Posted by Lund01 View Post
    That was idd what I was lookig for.
    Thanks. :)

    I knew the answer would be short, but I realy couldn't find it.
    You're welcome of course; the answer was obvious: you want part of a String so the API documentation for the String class is the place to be; it doesn't take rocket science to see that the substring( ... ) method could do the job (there are other ways to accomplish this).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. HashMap help
    By BobswYourUcle in forum New To Java
    Replies: 4
    Last Post: 05-06-2011, 09:05 PM
  2. Replies: 7
    Last Post: 12-08-2009, 07:17 PM
  3. Replies: 5
    Last Post: 07-28-2009, 10:22 PM
  4. what is hashmap
    By gabriel in forum New To Java
    Replies: 5
    Last Post: 08-03-2007, 01:23 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
  •