HashMap circle iteration

How to iterate HaspMap ?

1. First method :

private void addHeadersToHttpMethod(HashMap<String, String> headerMap,
            HttpEntityEnclosingRequestBase httpMethod) {
        //
        for (Entry<String, String> header : headerMap.entrySet()) {
            httpMethod.addHeader(header.getKey(), header.getValue());
        }
}

2. Second method :

HashMap hm = new HashMap();
hm.put(new Integer(1), "one");
hm.put(new Integer(0), "zero");
hm.put(new Integer(2), "two");

Set s = sm.entrySet();
// Using iterator in SortedMap
Iterator i = s.iterator();
while (i.hasNext()) {
    Map.Entry m = (Map.Entry) i.next();
    int key = (Integer) m.getKey();
    String value = (String) m.getValue();
    System.out.println("Key :" + key + "  value :" + value);
}