Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Iterator

  Asked By: Danielle    Date: Nov 20    Category: Java    Views: 720
  

1. Here is line 27 in WordList.java.
Iterator i = myWords.keySet().iterator();



a. Write the declaration header for the iterator method.

The question seems ambiguous to me. I know that class Iterator has
three methods hasNext(), next(), and remove() but concerning the Map
myWords.keySet() what exactly does iterator() stand for here. Of
course, the next line in the program is something like

while (iterator.hasNext())

but does myWords.keySet().iterator() mean iterator here is i.hasNext
()?

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abbad Akhtar     Answered On: Nov 20


> 1. Here is line  27 in WordList.java.
iterator  i = myWords.keySet().iterator();
>
>
>
> a. Write the declaration  header for the iterator method.
>
> The question  seems ambiguous to me. I know that class  Iterator has
> three methods  hasNext(), next(), and remove() but concerning the Map
> myWords.keySet() what exactly does iterator() stand  for here. Of

That I cannot tell as you have not told me what class myWords is.

> course, the next  line in the program  is something like
>
> while (iterator.hasNext())

surely you mean while ( i.hasNext() )

> but does myWords.keySet().iterator() mean iterator here is i.hasNext
> ()?

 
Didn't find what you were looking for? Find more on Iterator Or get search suggestion and latest updates.




Tagged: