Kesalahan: Tidak dapat menemukan simbol node newNode = node baru (input)
public class SinglyLinkedList
{
private Node head;
private Node tail;
private int size=0;
public Node add(Node n)
{
if(isEmpty())
{
head=n;
tail=n;
}
else
{
tail.next=n;
tail=n;
}
size ++;
return n;
}
public Node addFirst(Node n)
{
if(isEmpty())
{
head =n;
tail =n;
}
else
{
n.next = head;
head =n;
}
return n;
}
public Node getFirst()
{
return head;
}
public Node getLast()
{
return tail;
}
public boolean isEmpty()
{
return head == null;
}
public int size()
{
return size;
}
public static void main(String[] args)
{
SinglyLinkedList list = new SinglyLinkedList();
for(int i=0;i<10;i++)
{
Node n = new Node();
n.value="Miguel" + (i+1);
list.add(n);
}
Node n = list.getFirst();
while(n!=null)
{
System.out.println(n.value);
n = n.next;
}
}
}
Filthy Fowl