Results 1 to 3 of 3
  1. #1
    lenny is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Please help me with LinkedList in Java

    Hi, So I've got a LinkedList that I need to traverse through. Right now I'm going through it the same way that I would for a regular array, which works, it's just very slow. That is:
    Java Code:
    for (int i = 0; i < list.size(); i++)
    {
          code;
    }
    Can anyone help me with the correct way to go through the entire list?
    Thanks

  2. #2
    Swamipsn is offline Member
    Join Date
    Jul 2007
    Posts
    74
    Rep Power
    0

    Default

    Hi, why don't you try with Iterator...?

  3. #3
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    Yeah I second the iterator
    Java Code:
    Iterator it = list.iterator();
    while (it.hasNext())
    {
    object = it.next();
    //do stuff
    }

Similar Threads

  1. Creating Array of LinkedList
    By sasikumardr in forum New To Java
    Replies: 1
    Last Post: 12-11-2007, 10:25 AM
  2. Problem with LinkedList Java
    By paul in forum Advanced Java
    Replies: 2
    Last Post: 08-07-2007, 04:57 AM
  3. how to use LinkedList
    By fred in forum Advanced Java
    Replies: 1
    Last Post: 07-24-2007, 01:52 AM
  4. Problem with LinkedList
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 07-05-2007, 06:08 AM

Posting Permissions

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