File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Linked List Data Structure Implementation - No Java API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Linked List Data Structure Implementation - No Java API" Watch "Linked List Data Structure Implementation - No Java API" New topic
Author

Linked List Data Structure Implementation - No Java API

Dante Hawke
Greenhorn

Joined: Jan 27, 2009
Posts: 7
Hi all, I was hoping some of you may be able to help me.

I have been tasked with implementing a linked list data structure that does not use any imports, other than a provided interface. This implementation must store items in the order they are added.

I thought that I should use an inner class to act as the Node class for this linked list, as it has to remain as generic and abstract as possible and should work for any type of Object you wish to add.

BasicCollection interface:


BasicLinkedList class:


I am having problems testing my code by creating an instance of the BasicLinkedList class and adding some Integer objects, it fails on the 2nd line of the add method...

Can any of you provide any pointers or advise?

Many Thanks,

Dante.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3826

Hi Dante, Welcome to JavaRanch

I suggest you first start with non-generic approach, once you got it working you can make it generic.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38481
    
  23
Why isn't your size attribute static?
Until you have got it working, take out the Iterable interface.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Linked List Data Structure Implementation - No Java API