My method is not working for some reason, even though i have done in exactly the same way the books showed.
Could you please take a look at it and let me know what went wrong?
Thank you
P.S. I tried to use DEBUG technique and it seems that the method doesn't even go through the list.
public static IntNode listSearch(IntNode head, int target) {
IntNode cur;
for (cur = head; cur != null; cur = cur.link)
if (target == cur.data){
System.out.println("DEBUG" + cur.data);
}
else
System.out.println("DEBUG" + null);
return null;
}
this is how i call my method in main my.listSearch(null, 21); // method does not work