File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
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
Rancher

Joined: Mar 17, 2012
Posts: 892
    
    9
Post the full error message that you are getting and your Java version.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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?
Articles by Winston can be found here
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8008
    
  22

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://aspose.com/file-tools
 
subject: next() cannot override next() in my abstract list.