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

  • Home
  • SEARCH
  • 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 682173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:33:58+00:00 2026-05-14T01:33:58+00:00

How would you explain to someone who has just started programming in Java, what

  • 0

How would you explain to someone who has just started programming in Java, what the difference between ArrayLists and Iterators are?

Why I would use an iterator instead of using the get() methods of the Arraylist

  • 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-05-14T01:33:58+00:00Added an answer on May 14, 2026 at 1:33 am

    An ArrayList is an actual data structure, an implementation of the List interface. An Iterator is just an interface that allows you to navigate through any data structure (as long as an Iterator is available for that data structure).

    In other words, an ArrayList is an actual list of object references (or primitives) stored physically in an array. ArrayList is an “implementation” of the List interface, meaning it provides implementations of all the methods that are applicable to a List, such as add(object), remove(object), get(index), etc.

    Iterator is a more generic way to navigate through any data structure, be it a Set, a List, whatever. One important point is that it lets you navigate through every element in the data structure once, and then you’re done. From the documentation you can see that Iterator prescribes two methods, next() and hasNext(). next returns the next element in the underlying data structure, and hasNext lets you know if there even is a next element in the underlying data structure. Several data structures, ArrayList included, can provide you with an Iterator.

    Why I would use an iterator instead of using the get() methods of the Arraylist?

    Well, like many interfaces, Iterator allows you to do the same kind of thing no matter what the underlying implementation. If I want to “iterate” through some data structure, I can either

    a) write code that is specifically geared toward the data structure (such as an ArrayList) that I will have to change later if I change the data structure to something else (such as a HashSet) or

    b) obtain an Iterator from the data structure, and use the same hasNext/next technique that will work even if I change the data structure to something else.

    FYI, if you aren’t too familiar with the words “interface” and “implementation” you should probably do a Google search on “Java interface”.

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.