Giving compile time error

public void reverse(int k){

// Write your code here 
int m = this.size/k;
int initial=0;
    int fin=m-1;
for(int i=0;i<k;i++){
    
  Node left = getNodeAt(initial);
  Node right = getNodeAt(m-1);
  while(left<right){
      int temp=left.data;
      left.data=right.data;
      right.data=temp;
      }
   initial=initial+m;
   fin=fin+m;
}


}

kindly check and tell the mistake

Hi Ishant,
Since left and right are object of node class you cannot compare directly in while loop test condition i.e. left < right is wrong statement and that’s why you are getting compile time error.