Win a copy of Terraform in Action this week in the Cloud 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to fix @override "method does not override or implement a method from a supertype"

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright so Im working on a double linked list and writing a remove method which passes in a argument and throws a illegalStateException if there is no value passed into the variable lastItemReturned (which it has its a check)

my issue I cant seem to fix the error: "method does not override or implement a method from a supertype"

issue is at the public void remove(E remove) method and at the subclass cs340ListIterator which I get: cs340DLL.cs340ListIterator is not abstract and does not override abstract method remove() in ListIterator

am I not implementing the interface correctly and instead in the remove() method do



here is the class file:



any pointers ?

thanks guys as always
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at how many parameters the remove method in the ListIterator interface takes.
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ListIterator interface has a method remove() - note the lack of arguments. You haven't implemented that method, you've implemented a different one.
 
Sam Acropolis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohhh I see wow I totally missed that...but what If I wanted to pass parameters would I have to define a new remove method up above?
 
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sam Acropolis wrote: . . . I wanted to pass parameters would I have to define a new . . . method up above?

Yes. But what does “up above” mean?
 
Sam Acropolis
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Sam Acropolis wrote: . . . I wanted to pass parameters would I have to define a new . . . method up above?

Yes. But what does “up above” mean?



good question in more detail would defining a new method after :



work? Or does it go into the superclass(the class above the ListIterator subclass)
 
Campbell Ritchie
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would have to go into a named class somewhere. It does not necessarily have to be in the ListIterator class. It can go anywhere. Remember it is only visible to a reference to the type it is in. If you call the reference ListIterator, you won’t see that method.
 
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