Map<String,String> map = new HashMap<String,String>(); List list = new ArrayList(); list.add("565"); map.put("key", "value"); Iterator it =map.keySet().iterator(); while(it.hasNext()){ String a=(String) it.next(); System.out.println(map.get(a)); } Iterator its = list.iterator(); while(its.hasNext()){ System.out.println(its.next()); }