aspose file tools*
The moose likes Java in General and the fly likes Double Linked List error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Double Linked List error message" Watch "Double Linked List error message" New topic
Author

Double Linked List error message

Maria Macalino
Greenhorn

Joined: Jun 11, 2012
Posts: 12
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
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7029
    
  16

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.


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Sumit Patil
Ranch Hand

Joined: May 25, 2009
Posts: 296

Please don't create duplicate threads


Thanks & Regards, Sumeet
SCJP 1.4, SCWCD 5, LinkedIn Profile
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36453
    
  15
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
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36453
        
      15
    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
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36453
        
      15
    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

    Joined: Jun 11, 2012
    Posts: 12
    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.
    Stuart A. Burkett
    Ranch Hand

    Joined: May 30, 2012
    Posts: 679
    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
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36453
        
      15
    You can always write stub methodsThat will keep the compiler happy. Or, you can try what NetBeans does
    Winston Gutkowski
    Bartender

    Joined: Mar 17, 2011
    Posts: 7029
        
      16

    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
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Double Linked List error message
     
    Similar Threads
    RefList help
    Reversing a Linked List
    compiler will not accept setprev or getprev to make doubly linked listin
    Data Structures Double Linked List - moveUp and moveDown methods
    Java Linked List