public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        int source= sc.nextInt();
        int dest  =  sc.nextInt();
        int noOfVertices= sc.nextInt();
        int noofEdges= sc.nextInt();
        int GreeLights[] = new int[noOfVertices+1];
        HashMap<edge, Integer> edgeInfo= new HashMap<>();
        Graph g= new Graph();
        for(int i=1;i<=noOfVertices;i++){
            GreeLights[i]=sc.nextInt(); 
        }
        for(int i=1;i<=noofEdges;i++){
            int x= sc.nextInt();
            int y= sc.nextInt();
            int weight= sc.nextInt();
            edge e= new edge(x,y);
            edgeInfo.put(e, weight);
            g.adj.put(x, new LinkedList<Integer>());
            g.addNeighbour(x, y);
        }
        boolean visited[]= new boolean[noOfVertices+1];
        int distance[]= new int[noOfVertices+1];
        for(int i=1;i<=noOfVertices;i++){
            visited[i]=false;
            distance[i]=1000;
        }
        distance[source]=0;
        for(int i=1;i<=noOfVertices;i++){
            int min=1000;
            int minIndex=-1;
            for(int j=1;j<=noOfVertices;j++){
                if(distance[j]<min){
                    min=distance[j];
                    minIndex=j;
                }
            }               
            visited[minIndex]=true;
            LinkedList<Integer> LL= g.getNeighbors(minIndex);
            for(int x:LL){
                if(visited[x]!=true){
                    edge e = new edge(minIndex,x);
                    int weightofEdge=edgeInfo.get(e); //Null pointer exception occuring here
                    int distancetoNeighbour =    
              distance[minIndex]+weightofEdge;
                    if(distance[x]>distancetoNeighbour){
                        int greenTime=GreeLights[x];
                        int wait=0;
                        for(int j=0;j<distancetoNeighbour;){
                            j=j+greenTime;
                            wait=j;
                        }
                        wait-=distancetoNeighbour;
                        if(wait==0){
                            distance[x]=distancetoNeighbour;
                        }
                        else{
                            distance[x]=distancetoNeighbour+wait;
                        }
                    }
                }
            }
        }
        System.out.println(distance[dest]);
    }
I created a hashmap to store the edge as key and the weight of that edge as value. Now applied Dijkstras algorithm to solve my problem in which I need to get the weight value corresponding to an edge. So I make a new edge having vertices same as the required edge present in the hashmap but when I call edgeInfo.get() function to get the weight value of that edge it shows NullPointerException...can anyone help me..
My edge class is :-
  class edge{
  int x;
 int y; 
 public edge(int x,int y){
    this.x=x;
    this.y=y;
}
public boolean equals(edge e){
    return (this.x==e.x && this.y==e.y);
}   
 }
 
     
     
    