I am trying to traverse a doubly linked linked list but i seem to get an infinite loop. My goal is to find the first left most occurrence of an element in the list. I find the element but my program seems to keep looping. The only way to stop it from looping is breaking. There has to be another way. Thanks. {
Node<E> temp;
temp = head;
while(temp.next != null){
if(temp.value==obj){
System.out.println("YES");
}
else{
temp = temp.next;
}
System.out.println("nNO");
}
}
