-2

I want to get properteis from HashMap.

HashMap<String, Object> getProperties()

I want to get the properties which is true.

Brijesh Thakur
  • 6,768
  • 4
  • 24
  • 29
mstfdz
  • 2,616
  • 3
  • 23
  • 27

3 Answers3

3

Example:

HashMap<String, String> newMap = new HashMap<String, String>();
newMap.put("property", "shhh_secret");
String value = newMap.get("property");

or

Set s = newMap.keySet();  
for (Iterator iter = s.iterator(); iter.hasNext())  {  
  newMap.get(s);  
} 

or

Iterator iter = newMap.keySet().iterator();  
while (iter.hasNext()) {  
          ... 
} 

Source and more examples

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Boris Mocialov
  • 3,439
  • 2
  • 28
  • 55
0

This will help to read values from HashMap..Simple example

    HashMap<Integer, String> hm = new HashMap<Integer, String>();
    hm.put(1, "One");
    hm.put(2, "Two");
    hm.put(3, "Three");

    Set st = hm.entrySet(); //hm.keySet();
    for(Iterator itr = st.iterator(); itr.hasNext();)
    {
        //hm.get(st);
        System.out.println(itr.next());
    }
Karunagara Pandi
  • 634
  • 7
  • 16
  • 27