Thursday 22 January 2015

How to use Hashmap in java

import java.util.HashMap;
import java.util.Map;


public class HashmapExample {

    public static void main(String[] args) {

      HashMap<Integer, String> name=new HashMap<Integer, String>();
      name.put(1001,"Dx");
      name.put(1002,"Ravi");
      name.put(1003,"Mitul");
      name.put(1004,"Bittu");
      name.put(1005,"Dhaval");
     
      for(Map.Entry m:name.entrySet())
      {
          System.out.println(m.getKey()+"  "+m.getValue());
         
      }
    
    }

}















No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...