I am trying to input an int into the end of a singly linked list. I have already created the code to put a number at the end of the list but when I go to print it out, it only prints out (in my test class) the int that will go at the end of the list rather than printing out the whole list(and then .
If you already use an iterator, you should the iterator's method. The way you do (using for-loop from the list size) is unsafe and may cause problem. Use while(anIterator.hasNext()) is much safer.
Now, are you sure that your addEnd() method is implemented correctly? If the result is unexpected, you may … Read More