Iterator i1=h1.iterator();
while(i1.hasNext()){
int p=(int)(i1.next());
}
Please explain this code in python programming language term, here h1 is linkedhashset Thanks in advance
Iterator i1=h1.iterator();
while(i1.hasNext()){
int p=(int)(i1.next());
}
Please explain this code in python programming language term, here h1 is linkedhashset Thanks in advance
Copyright © 2021 Jogjafile Inc.
You have different ways to iterate a "LinkedHashSet", for example using: "forEach" or "iterate".
An iterator is an object that can be used to iterate all the elements in a collection. The Iterator has two important methods (hasNext, next).
I put an explanation about each line of your code
Also with an Iterator you can add or remove elements.
Additional resources:
Java Iterator - Geeks for Geeks
Java official Documentation