This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Linked List Data Structure Implementation - No Java API

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dante, Welcome to JavaRanch

I suggest you first start with non-generic approach, once you got it working you can make it generic.
 
Marshal
Posts: 70266
282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why isn't your size attribute static?
Until you have got it working, take out the Iterable interface.
 
    Bookmark Topic Watch Topic
  • New Topic