Detected code, here are some useful tools:
Formatted code
public <E> int removeAfter(Node<E> first, E target) {
int count = 0;
Node<E> temp = first;
while (temp != null ) {
if (temp.getData().equals(target)) {
if (temp.getData().equals(temp.getNext().getData())) {
continue ;
}
else {
temp.setNext(temp.getNext().getNext());
temp.getNext().clear();
count++;
}
}
temp = temp.getNext();
}
return count;
}