• 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

Double Linked List error message

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to work on a DoubleLinkedList code and ran into a few errors I couldn't fix.
The error I am getting is for DoubleLinkedList.java and is on the 4th line: (I could be doing my whole code wrong but I am only getting this 1 error. I would appreciate any help or feedback. I have not coded in java in so long so I'm very rusty.

DoubleLinkedList.java:4: lists.DoubleLinkedList is not abstract and does not override abstract method size() in lists.CustomList
public class DoubleLinkedList<T extends Comparable<T>> implements CustomList {
^
1 error

My codes:

MAIN


CustomList.java


DoubleNode.java

DoubleLinkedList.java
 
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

Maria Macalino wrote:My codes:...


Maria,

Please don't put very long lines inside code blocks (see the UseCodeTags page). It screws up the windowing here and makes things hard to read.
I've broken up a few of those long comments for you, but please remember in future.

Thanks.

Winston

PS: I also removed some redundant blank lines. Smaller usually == better.
 
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't create duplicate threads
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, where is your size() method? You wrote in your interface that there would be a size() method, but you haven’t written one.

Suggestion
  • 1: You have a private static int size field in your node class.
  • 2: Your add() insert() etc methods all include the statement size++;
  • 3: Your remove() delete() or excise() methods similarly include size--;
  • 4: You now know what to return from the size() method.
  • 5: This technique may not work correctly if you have two lists simultaneously; the size() method will probably return the sum of their sizes
  • 6: You now know enough to solve that last problem.
  •  
    Campbell Ritchie
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Don’t use /*...*/ to comment out blocks of code. Use // on each line. If there are any /**..*/ or /*..*/ comments in the block you are trying to comment out, only // will work reliably. Also, don’t quote commented‑out code here unless there is a specific problem in it which you want us to read.
     
    Campbell Ritchie
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Sumit Patil wrote:Please don't create duplicate threads

    That other thread is probably not a duplicate, but thank you for noticing.
     
    Maria Macalino
    Greenhorn
    Posts: 12
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thank you all for your posts. Sorry about the incorrect format. I am new here and I promise to make it shorter in the future and I'll fix the comments in the future.

    I haven't finished writing the rest of my code because I wanted to see if it would compile as is first before I keep going. I'm trying to get rid of that error first.
     
    Ranch Hand
    Posts: 679
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Despite the regular good advice on here to write only a few lines at a time before compiling, this isn't possible when you are writing a non-abstract class that implements an interface. You have to implement all the interface's methods before it will compile. A common approach in such cases is to have each of the methods throw an UnsupportedOperationException until you get round to doing the proper implementation.
     
    Campbell Ritchie
    Marshal
    Posts: 79151
    377
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You can always write stub methodsThat will keep the compiler happy. Or, you can try what NetBeans does
     
    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

    Maria Macalino wrote:Thank you all for your posts. Sorry about the incorrect format. I am new here and I promise to make it shorter in the future and I'll fix the comments in the future.


    No probs. It's more for you, because it makes your posts easier to read.

    Winston
    reply
      Bookmark Topic Watch Topic
    • New Topic