Circular LinkedList

Can you please detect error in the code?

import java.util.*;
public class Main
{
public static void main(String[] args) {
LinkedList ll= new LinkedList();
Scanner sc = new Scanner (System.in);
int n=sc.nextInt();
for(int i=0;i<n;i++)
{
ll.addLast(sc.nextInt());
}
boolean ans=ll.detectRemoveLoop();
if(ans==true)
{
ll.display();
}
else
{
System.out.print("-1");
}
}
}

class LinkedList
{
private class Node
{
int data;
Node next;
}

private Node head;
private Node tail;
private int size;

public void display()
{
    Node temp=head;
    while(temp!=null)
    {
        System.out.print(temp.data+" ");
        temp=temp.next;
    }
}

public void addLast(int item)
{
    Node nn= new Node();
    nn.data=item;
    nn.next=null;
    
    if(size>=1)
    {
        this.tail.next=nn; 
    }
    
    if(this.size==0)
    {
        this.head=nn;
        this.tail=nn;
        this.size++;
    }
    else
    {
        this.tail=nn;
        this.size++;
    }
}

public boolean detectRemoveLoop() 
{

    // detect loop
    Node slow = head;
    Node fast = head;

    while (fast != null && fast.next != null) {

        slow = slow.next;
        fast = fast.next.next;

        if (slow == fast)
            break;
    }

    if (slow == fast) 
    {
        // loop remove
        Node start = head;
        Node loop = slow;

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

    } 
    else 
    {
        return false;
    }

}

}

in your code, you will never have a cycle.
for eg. 1 2 3 4 5 1 2 -1
now 5 is pointing back to 1 which means a cycle. but your code will create a new node for second 1 and thus no cycle. whenever a value occurred again, you should point to the node already created for that value. but you are creating every time a new node. hense it will never have a cycle.
hint: use HashMap to detect already occurred value.

thanks