This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes  implement a list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark " implement a list" Watch " implement a list" New topic
Author

implement a list

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 331
Hi

I have the question. I am trying to discover the answer , but I have no idea.



Any ideas, please?

Regards
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3419
    
  12
Well the ArrayList class uses an array internally, so that would probably be a good approach to take.

Joanne
Mack Wilmot
Ranch Hand

Joined: Jul 27, 2011
Posts: 88

There are a couple of basic underlying structures you can use for a list, depending on how it is to be used. One is easy to access elements with an index and the other is more efficient for inserting elements into the middle of the list. The required methods in the question points toward one of these structures, do you know which one and what it is?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37926
    
  22
Or you can search posts from today and yesterday and see how people are implementing linked lists. You would obviously have to write your own code, only using what you find as inspiration.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3419
    
  12
Mack Wilmot wrote:One is easy to access elements with an index and the other is more efficient for inserting elements into the middle of the list.

The specification never said it had to be efficient
Mack Wilmot
Ranch Hand

Joined: Jul 27, 2011
Posts: 88

Joanne Neal wrote:
Mack Wilmot wrote:One is easy to access elements with an index and the other is more efficient for inserting elements into the middle of the list.

The specification never said it had to be efficient


It doesn't require inserting elements into the middle of the list either.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: implement a list
 
Similar Threads
How to get List elements
Collection
Locking scheme
ArrayList
most efficient way to remove duplicates from list?