Hello.
I am having a problem with this certain code. Every call with this method (listI()) will return a node. After the list reaches null, it will go back to the start. On the first call on the tester, there is no problem. But when the method is called for the second time, it does not stop. What's wrong with the code? What are the possible remedies I can do for this code?
Node listI(){
Node e = null;
Node idx = start;
int c = 0;
while(idx!=null){
c++;
idx = idx.next;
}
idx = start;
if(c == count){ //count is a global variable.
idx = idx.next;
e = idx;
if(idx == null){
e = null;
idx = start;
}
}else{
count = c;
idx = idx.next;
e = idx;
if(idx == null){
e = null;
idx = start;
}
}
if(e == null){
System.out.println("End of list");
}
return e;
}