Because your teacher is on the ball and wants to make your code fail if you use the == operator.
luan perre wrote:. . . I'm not sure why my professor decided to go with new Integer to test the remove method.
Not method, but constructor.
I am aware it's one of the deprecated methods. . . .
Campbell Ritchie wrote:Line 5. that comment is incorrect; you are not creating a empy List, but a one‑element List with an empty node.
Your updated code looks a lot better, but I am still worried about your using first.next rather than plain simple first. And what you said there means your counting is incorrect, I am afraid. A miss is as good as a mile, and one wrong result raises concerns about all results. The error might be in the remove() method, as you suggest, in which case it might only occur if you declare your reference as List.
luan perre wrote:. . . check that the number of elements is correct. All but the remove method return the correct amount.
luan perre wrote:
Normally I would create helper methods to aide my methods like isEmpty() or hasNext() but the way that this assignment is put together, we're only to fill in toString(), clear(), remove(E e), push(E e), pop(), and top();
So although there are things i would have done differently, I'm not to change anything from the other methods.
Campbell Ritchie wrote:Is that because the remove(int) method is different from the remove(E) method?
That means I am getting confused between the current List interface and java.util.List, which does have a remove(int) method. Sorry for my mistake.
Junilu Lacar wrote:. . . I didn't see a remove(int) method. . . . .
I am not young enough to know everything. - Oscar Wilde This tiny ad thinks it knows more than Oscar:
Create Edit Print & Convert PDF Using Free API with Javahttps://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire