Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:20:35+00:00 2026-06-15T12:20:35+00:00

I need to know how to "reset" LinkedList iterator to its first element. For

  • 0

I need to know how to "reset" LinkedList iterator to its first element.

For example:

LinkedList<String> list;
Iterator iter=list.listIterator;
iter.next();
iter.next();

Over and over again and after many moves of the iterator, I need to "reset" the position of the iterator.

I want to ask how I can "reset" my iterator to the first element.

I know that I can get list iterator of the first element in this way:

iter= list.listIterator(1);

Is this the best solution? Or maybe I missed something in Oracle docs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:20:37+00:00Added an answer on June 15, 2026 at 12:20 pm

    Best would be not using LinkedList at all, usually it is slower in all disciplines, and less handy. (When mainly inserting/deleting to the front, especially for big arrays LinkedList is faster)

    Use ArrayList, and iterate with

    int len = list.size();
    for (int i = 0; i < len; i++) {
      Element ele = list.get(i);
    }
    

    Reset is trivial, just loop again.
    If you insist on using an iterator, then you have to use a new iterator:

    iter = list.listIterator();
    

    (I saw only once in my life an advantage of LinkedList: i could loop through whith a while loop and remove the first element)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know how to change background of expanded list item when it
For example, I get a string: str = "please answer my question" I want
$(".guide").focus(function(){ $(this).removeClass("guide").val(""); }); I just need to know if there's something else I need
I have, for example, this string: asd? asdfasdfsdf <description>&lt;div? style=&quot;color:000000;font-family:Arial, Helvetica, ?sans-serif;font-size:12px;font-size:12px;width:555px;&quot;&gt;Bohus Malm?t;/a&gt;</description> blah
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It
I need to know how to exclude files/folders from php generated zip. Here is
I need to know on a continuous basis when my UIScrollView is scrolling or
I need to know a couple of things, concerning IRC servers that I couldnt
I need to know how many instances of my process are running on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.