Help me in solving DSAJ28 problem

My issue

public void middleElement1(){
node slow = head;
node fast = head;
while(fast!=null && fast.next!=null){
slow=slow.next;
fast=fast.next.next;
}
System.out.println(slow.value);
}
public void middleElement2(){
node slow = head;
node fast = head;
while(fast!=null && fast.next!=null && fast.next.next!=null){
slow=slow.next;
fast=fast.next.next;
}
System.out.println(slow.value);
}

Learning course: DSA using Java
Problem Link: MCQ - Find middle element Practice Problem in DSA using Java - CodeChef