| Author |
next() cannot override next() in my abstract list.
|
Edward Strife
Greenhorn
Joined: Mar 15, 2012
Posts: 14
|
|
I get an error when calling next() during my return SalesPerson method.
Here is the SortedListOfSalesperson:
And my abstract list class:
|
 |
E Armitage
Ranch Hand
Joined: Mar 17, 2012
Posts: 220
|
|
|
Post the full error message that you are getting and your Java version.
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4734
|
|
Edward Strife wrote:I get an error when calling next() during my return SalesPerson method.
Because AbstractList does not define a next() method. I suspect you're confusing an AbstractList with its Iterator.
I think you'd also be much better off if you use generics, viz:
public class SortedListOfSalesperson extends AbstractList<SalesPerson> { ...
you'll find everything a lot easier (and you won't need to cast).
Winston
|
Isn't it funny how there's always time and money enough to do it WRONG?
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Winston Gutkowski wrote:
Edward Strife wrote:I get an error when calling next() during my return SalesPerson method.
Because AbstractList does not define a next() method. I suspect you're confusing an AbstractList with its Iterator.
Not really. This AbstractList is an own class, not the one from java.util.
Edward, does SalesPerson implement Comparable, either directly or indirectly? Because covariant returns would allow you to change the return type as long as it's a sub type of the original (Comparable).
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4734
|
|
Rob Spoor wrote:Because AbstractList does not define a next() method. I suspect you're confusing an AbstractList with its Iterator.
Ooops. Missed that. Sorry OP.
Winston
|
 |
 |
|
|
subject: next() cannot override next() in my abstract list.
|
|
|