0

hello can you help me i don't know how to make this method remove(Node n),in SinglyLinkedList can anyone give a hand on this..

thank you in advance.hoping for your positive responds...

```
public class SinglyLinkedList
{
private Node head;
private Node tail;
private int size = 0;
public Node add(Node n)
{
if(isEmpty())
{
//if list is empty new node n should be the tail and head
head = n;
tail = head;
}
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 getSize()
{
size++;
return size;
}
public Node insertAfter(Node n, Node target)
{
if (head==null)
{
head=n;
tail=n;
}
else
{
n.next=target.next;
target.next=n;
}
return n;
}
public Node remove(Node n)
{
}
public static void main(String[] args)
{
SinglyLinkedList list = new SinglyLinkedList();
for(int i=0;i<10;i++)
{
Node n = new Node();
n.value = "jemzgimz" + (i + 1);
list.add(n);
}
// insertAfter
Node x = new Node();
x.value = "jemz";
Node target = list.getFirst();
list.insertAfter(x,target);
System.out.println("The size of list: " + list.size);
Node s = list.getLast();
Node n = list.getFirst();
while(n!= null)
{
System.out.println(n.value);
n = n.next;
}
}
}
```

*Edited 6 Years Ago by jemz*: n/a