java – Iterator in MVC pattern


I'm doing a project and I was asked to build an Iterator class in it. This entire project is being built based on the MVC standard. So what would this Iterator class be and how am I going to use it? From what I've been researching it seems to have some use in implementing structures (lists, stacks, etc), but I didn't quite understand.


An Iterator or Iterator is used to check and iterate through data structures, as mentioned, Lists, Stacks, Queues, Sets, Tree, in an iterator you will implement checks to see if there are more elements within the structure, method to return an element of this structure and etc.

Most or if not all programming languages ​​already come with ready-made and implemented structures for the developer to just use, if you are going to perform the implementations of an Iterator manually, you will use Arrays building the logic in each necessary method, making it as dynamic as possible. so that lists can grow and shrink as you use them.

The Iterator shouldn't have any connection to the MVC architectural pattern, it's possible that you've seen something referring to layers by the division of responsibility when implementing the Iterator in different data structures, yet it seems unlikely.

Scroll to Top