Linked list dectect cycle and remove

why it give wrong answer?
explain how to remove detect loop?
i have doubt in second while loop of start and loop
how it remove detect loop
import java.util.*;
public class LinkedList {

public class Node 
{
  int data;
  Node next;

 public Node(int data)
    {
	  this.data=data;
	} 
}
private int size;
private Node head;
private Node tail;

public  void add(int d)
   {
      Node nn=new Node(d);
	
	  if(head==null)
	     {
			 head=nn;
			 tail=nn;
		 }
		
		else
		{
		  tail.next=nn;
		  tail=nn;
		}   
   }
  public  void display()
      {
		  Node temp=head;
		  while(temp!=null)
		     {
				 System.out.print(temp.data+" ");
				 temp=temp.next;
			 }		    
	  }		
  public  void dloop()
      {
        Node slow=this.head;
		Node fast=this.head;

		while(fast!=null || fast.next!=null)
		   {
              slow=slow.next;
			  fast=fast.next.next;

			  if(slow==fast)
			     break;
		   }
		      
         if(slow==fast)
		    {
               Node start=head;
			   Node loop=slow;

			   while(start.next!=loop.next)
			      {
                     start=start.next;
					 loop=loop.next;
				  }

				 loop.next=null; 
			}
	  }		
    
public static void main(String args[]) {
     
    Scanner kb=new Scanner(System.in);
	LinkedList list=new LinkedList();
	int a=kb.nextInt();

        while(a!=-1)
		    {
			   list.add(a);
			   a=kb.nextInt();
			}

     
  list.dloop();	
	 list.display();		
    }

}

@abhishekg,
To remove the loop:

  1. Count the number of nodes in loop. Let the count be n.
  2. Fix one pointer to the head and another to nth node from head.
  3. Move both pointers at the same pace, they will meet at loop starting node.
  4. Get pointer to the last node of loop and make next of it as NULL.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.