HashMap to implement adjacency list
<pre><code>class Graph {
//Map of adjacency lists for each node

    Map&lt;int[], LinkedList&lt;int[]&gt;&gt; adj;

    public Graph(ArrayList&lt;int[]&gt; nodes) {
        adj = new HashMap&lt;int[], LinkedList&lt;int[]&gt;&gt;();
        for (int i = 0; i &lt; nodes.size(); ++i) {
            adj.put(nodes.get(i), new LinkedList&lt;int[]&gt;());
        }
    }

    public void addNeighbor(int [] a, int [] b) {
        adj.get(a).add(b);
    } 

    public LinkedList&lt;int[]&gt; getNeighbors(int a[]) {
        return adj.get(a);
    }
}


public class Assignment2 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x= sc.nextInt();
        int y= sc.nextInt();
        int n= sc.nextInt();

        ArrayList&lt;int []&gt; al= new ArrayList&lt;&gt;();
        for(int i=0;i&lt;n;i++){
            int[] a = new int[2];
            a[0]=sc.nextInt();
            a[1]=sc.nextInt();
            al.add(i, a);
        }
        int[] s={0,100};
        int[] t={x-5,150};
        Graph g = new Graph(al);
        g.adj.put(s, new LinkedList&lt;int[]&gt;());
        g.adj.put(t, new LinkedList&lt;int[]&gt;());
        for(int i=0;i&lt;al.size();i++){
            int a[]=al.get(i);
            for(int j=i;j&lt;al.size();j++){
                int b[]=al.get(j);
                int r=100;
                int value=(int) (Math.pow(a[0]-b[0],2)+Math.pow(a[1]-b[1],2));
                if(0&lt;=value &amp;&amp; value &lt;=200){
                g.addNeighbor(a, b);
                g.addNeighbor(b, a);
            }   
        }
    }
}
</code></pre>

<p>I have to implement an adjacency list to be used for graph for which I have used a HashMap as you can see the key value is an array which contains coordinates value (x,y) which represents a vertex in the graph. </p>

<p>The problem is when I want to add a new neighbour into the graph i.e add an edge between two vertices I need to add that neighbour to the respective key but that key is an array... so I want to know how do I that access key or add to the neighbours at that key. What I did is I created a new array having values equal to the key array stored in the hashmap but these two are not equal. </p>

<p>Please suggest a solution or any other way to store the coordinates   </p>