• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 22787
131
Eclipse IDE Spring 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
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic