Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

next() cannot override next() in my abstract list.

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get an error when calling next() during my return SalesPerson method.
Here is the SortedListOfSalesperson:



And my abstract list class:


 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Post the full error message that you are getting and your Java version.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 22568
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic