How do I output Java HashMap keys when the 'key' is two integers?
<pre><code>    package point;

    //an array arr is populated with random x,y points using MyPoint then
    public static void main(String[] args) throws IOException {
    HashMap&lt;MyPoint,Integer&gt; map = new HashMap&lt;MyPoint,Integer&gt;();
    Integer val =0;

    for(int i = 0; i &lt; arr.length ; i++)
    {
        map.put(arr[i],val);
    }
    }


//second file.
package point;
public class MyPoint implements Comparable&lt;MyPoint&gt;{

private int x;
private int y;

public MyPoint(int x1, int y1) {
    x = x1;
    y = y1;
}

public boolean equals(Object p) {
    MyPoint p1;
    try {p1 = (MyPoint) p;}
    catch (ClassCastException ex) {return false;}
    return (x == p1.x) &amp;&amp; (y == p1.y);
}

public int hashCode() {
    return ((y * 31) ^ x);
}
</code></pre>

<p>Here is my code MyPoint stores x y points. I'm using this code to get unique sets of x,y points with no duplicates. </p>

<p>My Question is how do I retrieve the x y values in MyPoint ? Is this an efficient way to use a HashMap to filter unique X,Y points. Also here is the HashCode I made.</p>

<p>Is there a better HashCode I could use?</p>
