Results 1 to 2 of 2
  1. #1
    trying is offline Member
    Join Date
    Jan 2012
    Posts
    16
    Rep Power
    0

    Default How to return a hashmap key using the value?

    Hi

    How do you return a key that relates to a value?

    I have a hashmap - Map <String,ArrayList<Integer>>

    which I wish to write a method for that scans through the ArrayList<Integer> and returns the key of a given is within the ArrayList

    thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to return a hashmap key using the value?

    Quote Originally Posted by trying View Post
    Hi

    How do you return a key that relates to a value?
    You don't. There is no guaranteed one-to-one correspondence between value and key (as opposed to the other way around).

    I have a hashmap - Map <String,ArrayList<Integer>>
    which I wish to write a method for that scans through the ArrayList<Integer> and returns the key of a given is within the ArrayList
    This post is not clear to me at all. What exactly are you trying to do again? What code do you have?

Similar Threads

  1. Cannot return items from a hashmap
    By uhertz in forum New To Java
    Replies: 15
    Last Post: 06-20-2011, 03:06 AM
  2. Cannot return values from hashmap
    By uhertz in forum New To Java
    Replies: 1
    Last Post: 06-17-2011, 05:16 PM
  3. Replies: 7
    Last Post: 12-08-2009, 08:17 PM
  4. HashMap String Return
    By kizilbas1 in forum New To Java
    Replies: 1
    Last Post: 03-10-2008, 04:34 AM
  5. how to return values from hashmap
    By oregon in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 05:56 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
  •