Results 1 to 3 of 3
  1. #1
    tempme is offline Member
    Join Date
    Feb 2015
    Posts
    3
    Rep Power
    0

    Default iterate through objects

    Hi,

    I would like to know how I can iterate through objects . I have a manually created linked list (without using the built-in method one). So in the memory my object looks like this(attachment).

    I would like to do a for loop or while loop to get each element under the test3.head.
    Any tip or advice will be appreciated.


    Thanks
    Attached Thumbnails Attached Thumbnails iterate through objects-temp.png  
    Last edited by tempme; 02-27-2015 at 01:25 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: iterate through objects

    Here it is in pseudo code.

    node = first node
    do
    print data stored in node.
    node = node.next
    while node != null // assumes last node points to null at end of list

    May need some tweaking to accommodate actual linked list.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    tempme is offline Member
    Join Date
    Feb 2015
    Posts
    3
    Rep Power
    0

    Default Re: iterate through objects

    Thanks, that was helpful. I'm now able to iterate .

    Thanks

Similar Threads

  1. How do I iterate
    By Nilla in forum New To Java
    Replies: 7
    Last Post: 06-23-2012, 08:23 AM
  2. How to iterate over objects in a class?
    By Neilos in forum New To Java
    Replies: 10
    Last Post: 08-18-2011, 08:02 PM
  3. iterate through a HashMap ?
    By aneuryzma in forum New To Java
    Replies: 2
    Last Post: 03-27-2011, 03:26 PM
  4. How to iterate through two Arrays?
    By aRTx in forum Advanced Java
    Replies: 3
    Last Post: 05-18-2010, 07:48 AM
  5. Iterate Text File
    By Boaz in forum New To Java
    Replies: 5
    Last Post: 03-17-2009, 08:55 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
  •