My reversePointer function is getting into infinite loop

public void reversePointers() throws Exception{

    Node prev = this.head;
    Node curr = prev.next;

    while (curr != null){

        Node ahead = curr.next;

        curr.next = prev;

        prev = curr;
        curr = ahead;

    }

    //swap

    Node temp = this.head;
    this.head = this.tail;
    this.tail = temp;

public void reversePointers() throws Exception{

    Node prev = this.head;
    Node curr = prev.next;

    while (curr != null){

        Node ahead = curr.next;

        curr.next = prev;

        prev = curr;
        curr = ahead;

    }

    //swap

    Node temp = this.head;
    this.head = this.tail;
    this.tail = temp;

Hey @syedfaisaljaved
Your logic is right.
You missed a line in the code.
You had to include the line
this.tail.next = null;
at the last.
I’ve made correction in your code. You can check that here.
https://ide.codingblocks.com/s/49652