Glad you got it working.
Type: Posts; User: Norm
Glad you got it working.
Have you worked through the logic of what the code is doing? Play computer with it and see what it does.
Why do you expect it to go through the list more than once?
For solving these kinds of problems you must use paper and pencil and work through your logic. In the code add enough printlns to see what is happening and then compare it with what you have worked...
One thing I see is that you are printlng out the values that are being tested: if(dateCheck.before(date))
For solving these kinds of problems you must use paper and pencil and work through your...
You need to post the code that shows the logic and that can be executed for testing.
The code loses the first element and has two copies of the 3rd.
Time for some design work with a paper and pencil.
I changed the debug print out to give more info:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import...
I see two dates. Which date is it supposed to sort on?
Can you make a small simple program that compiles and execute and shows the problem. Hardcode the data into the program so no extra files are required.
How can I test it?
hasNext() will stay true until you remove all the items from the iterator.
Now you need to print out the values of the variables that are causing the infinite loop Then try to see why the code does not change them to allow the loop to exit.
Let us know when you have working code to test.
Or try debugging the code yourself. If you don't use an interactive debugger, add lots of println statements to show execution flow and the values of...
Can you print out the list before the sort and again after the sort to show what the code is doing?