title: Use custom class in HashMap in android
body: <p>EDIT: I have posted it earlier for java. But it working in Java but not in android. So I am posting the android code now.</p>
  
  <p>I am trying to use a custom class into a HashMap in my android application. But it is not giving my desired output. Please help.</p>
  
  <p>I want to do something like this...</p>
  
  <p>//Code for android application:</p>
  
  <p>//Point class</p>
  
  <pre><code>class Point{
   private int x;
   private int y;
  
  public Point(){
  
  }
  public Point(int _x, int _y){
    this.x = _x;
    this.y = _y;
  }
  
  }
  </code></pre>
  
  <p>DataManager.java</p>
  
  <pre><code>public class DataManager {
  
      private Vector&lt;Integer&gt; RSSI = null;
      private int numOfRSSI;
  
      private Map&lt;Vector&lt;Integer&gt;, Point&gt; SingleData = null;
      private Vector&lt;Map&lt;Vector&lt;Integer&gt;, Point&gt;&gt; Data = null;
      private Context context;
  
      public DataManager(Context _context) {
          this.context = _context;        
          Data = new Vector&lt;Map&lt;Vector&lt;Integer&gt;, Point&gt;&gt;();
      }
  
      public void loadData(String filename) {
          if (Data == null) {
              System.out.println("***ERROR: DataSet not initalized!!!\n");
          }
          readFile(filename);
      }
  
      public void printData(){        
          Vector&lt;Integer&gt; rssi = null;
          Map&lt;Vector&lt;Integer&gt;, Point&gt; single = null;
          Point point = null;
  
          for(int i=0;i&lt;Data.size();i++){
          single = new HashMap&lt;Vector&lt;Integer&gt;, Point&gt;() ;
          single = Data.get(0);
  
          for (Map.Entry&lt;Vector&lt;Integer&gt;, Point&gt; entry :single.entrySet()) {
  
                rssi = new Vector&lt;Integer&gt;();           
                point = new Point();            
                rssi = entry.getKey();
                point = entry.getValue();           
                System.out.print("("+point.x+" "+point.y+") ");
  
                for(int j = 0;j&lt;rssi.size(); j++){
                    System.out.print(rssi.get(j)+" ");
                }           
                System.out.println("");
          }       
          }       
      }
  
      private void readFile(String filename) {
  
          InputStream is = null;
          try {
              is = context.getResources().getAssets().open("datasets.txt");
          } catch (IOException e) {
              e.printStackTrace();
              System.out.println("error file reading");
          }
  
          if (is != null) {
  
              StringBuilder text = new StringBuilder();
              int flag = 0;
  
              try {
                  BufferedReader br = new BufferedReader(
                          new InputStreamReader(is));
  
                  String line;
  
                  while ((line = br.readLine()) != null) {
  
                      if(flag==0){
                          flag=1;
                          this.numOfRSSI = Integer.parseInt(line);
                          System.out.println("number of RSSI: "+numOfRSSI);
                      }
                      else if(flag==1){
                          parseLine(line);
                      }
  
                  }
  
              } catch (IOException e) {
                  // Error reading file
              }
  
              finally {
                  // myHelper.print(text.toString());
  
              }
          }
  
      }
  
      private void parseLine(String line) {
  
          RSSI = new Vector&lt;Integer&gt;();
          SingleData = new HashMap&lt;Vector&lt;Integer&gt;, Point&gt;();
  
  
          StringTokenizer st = new StringTokenizer(line, ",");
          int co = 0;
          int x=0,y=0;
          while (st.hasMoreTokens()) {
  
              if(co &lt; this.numOfRSSI){
                  RSSI.add(Integer.parseInt(st.nextToken()));
                  co++;
              }
              else{
                  x = Integer.parseInt(st.nextToken());
                  y = Integer.parseInt(st.nextToken());
              }
  
          }
  
          Point point = new Point(x,y);
  
          SingleData.put(RSSI, point);
  
          Data.add(SingleData);
      }
  
  }
  </code></pre>
  
  <p>MainActivity.java</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          // TODO Auto-generated method stub
          super.onCreate(savedInstanceState);
  
          DataManager dataManager = new DataManager(MainActivity.this);
  
          dataManager.loadData("datasets.txt");
  
          dataManager.printData();
      }
  
  }
  </code></pre>
  
  <p>datasets.txt</p>
  
  <p>5
  -61,-51,-46,-41,-28,1,0</p>
  
  <p>-60,-50,-51,-47,-34,2,0</p>
  
  <p>-72,-52,-53,-55,-37,3,0</p>
  
  <p>-60,-44,-58,-53,-40,3,1</p>
  
  <p>-68,-55,-46,-47,-45,2,1</p>
  
  <p>-66,-60,-48,-43,-37,1,1</p>
  
  <p>-62,-57,-49,-45,-34,0,2</p>
  
  <p>Output is showing.....</p>
  
  <p>1 0 -61 -51 -46 -41-28</p>
  
  <p>1 0 -60 -50 -51 -47 -34</p>
  
  <p>1 0 -72 -52 -53 -55 -37</p>
  
  <p>etc.....</p>
  
  <p>But it should be...</p>
  
  <p>1 0 -61 -51 -46 -41-28</p>
  
  <p>2 0 -60 -50 -51 -47 -34</p>
  
  <p>etc...</p>
  
  <p>So this is my problem.</p>