Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Map mymap = new HashMap();
- mymap.put("1","one");
- mymap.put("1","not one");
- mymap.put("1","surely not one");
- //the following line is case 2 for duplicate
- //mymap.put("1","one");
- System.out.println(mymap.get("1"));
- public V put(K key,
- V value)
- Map<String, ArrayList<String>> hashMap=new HashMap<String,
- while(it.hasNext()){
- String key=it.next().toString();
- tempList=hashMap.get(key);
- if(tempList!=null){
- for(String value: tempList){
- System.out.println("Key : "+key+ " ,
- } } ..... private void addValues(String key, String value){
- ArrayList tempList=null;
- if(hashMap.containsKey(key)){
- tempList=hashMap.get(key);
- if(tempList==null)
- tempList=new ArrayList();
- tempList.add(value);
- }else{
- tempList=new ArrayList();
- tempList.add(value);
- }
- hashMap.put(key,tempList);
- } .....
Add Comment
Please, Sign In to add comment