Iterator in Map. Flashcards
1
Q
- What is Iterator?
- How to Iterate a Entries ?
- Do you know while loop condition?
- What is the use of hasnext.
A
- Iterator is an interface in java, by using Iterator we can get all the entries in entry set.
- First change alll the key value pairs to entry set by using
Set s = cc.entrySet(); cc is the refrence name create while hashmap. - Yes i know,
Iterator i -= s.iterator;
while(i.hasnext())
{
system.out.println(i.next();
)
But using this it will print the value in entries key value pair
4.hasnext() it is like a condition it will check whether any values are the next.