Results 1 to 2 of 2
  1. #1
    plexus0208 is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Default How to use linkedlist 'add' method without iterator

    public void add(int n, Object o)

    Can someone show me how to complete the above method for linkedlists? Basically, I want to insert objects at specific indexes of a linkedlist, without using the linkedlist iterator.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by plexus0208 View Post
    public void add(int n, Object o)

    Can someone show me how to complete the above method for linkedlists? Basically, I want to insert objects at specific indexes of a linkedlist, without using the linkedlist iterator.
    A LinkedList can do that (read its API documentation). It will be slower the more to the middle of the list you want to add/insert the element.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 0
    Last Post: 05-18-2010, 01:53 AM
  2. iterator method help..
    By mayhewj7 in forum New To Java
    Replies: 1
    Last Post: 04-08-2009, 04:45 AM
  3. [SOLVED] Writing an Iterator method in a custom list
    By xcallmejudasx in forum New To Java
    Replies: 2
    Last Post: 02-12-2009, 06:22 AM
  4. iterator
    By venkatallu in forum Advanced Java
    Replies: 3
    Last Post: 09-23-2008, 02:32 PM
  5. Iterator
    By eva in forum New To Java
    Replies: 0
    Last Post: 01-31-2008, 03:07 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •