This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes next() cannot override next() in my abstract list. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "next() cannot override next() in my abstract list." Watch "next() cannot override next() in my abstract list." New topic
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: 4761
    
    7

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: 4761
    
    7

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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: next() cannot override next() in my abstract list.
 
Similar Threads
Currency Problem + General Advice
need help with compareTo()
RefList help
Unable to add object to array.
Unsorted array list