Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Linked List Data Structure Implementation - No Java API

 
Dante Hawke
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.
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • 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.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic