Hi, this week in class we're working with LinkedLists and while my program runs when I use user ID as an int, my sentinel value "000" ends the program whenever an ID of "0", "00" or "000" is entered. I realised that 0 = 00 = 000, so to fix that I changed the ID from int value to string value. Now however, my code doesn't recognise any input and always outputs "No such customer".
I'm sure the issue I'm having is super simple. Also, if there's anything that I could do to fix/clean-up the code as I'm still learning Java. If possible, please explain why you do certain things so I can learn instead of just copy/pasting solutions, thanks!
One simple debugging technique is to put a bunch of System.out.println() statements in your code.
If you think the problem is in that method, do something like this:
You can then see EXACTLY what this method is doing...when you enter/leave it, how many times it loops, if it ever finds a match...Once you figure this out, you may learn that your matches() method doesn't return the correct value...or maybe your loop doesn't work right...but in any case, it helps you focus in on where the problem REALLY is.