how to add the elements in the Hashmap

Discussions

XML & Web services: how to add the elements in the Hashmap

  1. how to add the elements in the Hashmap (4 messages)

    Could some one please let me know how to add and read the elements from HashMap?

    Thanks
  2. how to add the elements in the Hashmap[ Go to top ]

    This is simple. HashMap stores key-value pair (both key and value must be an Object).

    In order to store a key-value (assume ref is the reference to a HashMap):
    ref.put(key, value);

    In order to retrieve a value with a key (you can always cast the return value if you know what specified type it is):
    Object value = ref.get(key);
  3. how to add the elements in the Hashmap[ Go to top ]

    I am trying the following sample I am getting error
    import java.lang.*;
    import java.util.*;
    public class Test
    {
       public static void main(String[] args)
        {
             HashMap hashmap = new HashMap();
              hashmap.put("type", "INTERACTION_TYPE");
              hashmap.put("code", "PHONE");
              hashmap.put("description", "PHONE");
           
        }
    }

    Can someone please let me know?

    Thanks
  4. I tried running this code and it works fine. What error are you getting?

    -SI
  5. Thanks It works.