For this Question: Given a circular linked list consisting of N nodes, your task is to exchange the first and last node of the list.

<b>Note:
Examples in Sample Input and Output just show how a linked list will look depending on the questions. Do not copy-paste as it is in custom input</b><b>User Task:</b>
Since this will be a functional problem, you don't have to take input. You just have to complete the function <b>exchangeNodes()</b> that takes head node as parameter.

Constraints:
3 <= N <= 1000
1 <= Node. data<= 1000Return the head of the modified linked list.Sample Input 1:-
3
1- >2- >3

Sample Output 1:-
3- >2- >1

Sample Input 2:-
4
1- >2- >3- >4

Sample Output 2:-
4- >2- >3- >1, I have written this Solution Code:   public static Node exchangeNodes(Node head) {
               
                Node p = head; 
    while (p.next.next != head) 
    p = p.next; 
      
    p.next.next = head.next; 
    head.next = p.next; 
    p.next = head; 
    head = head.next; 
  
    return head; 
        
    }, In this Programming Language: Java, Now tell me if this Code is compilable or not?