Monday, 9 September 2013

When to create iterator for a list?

When to create iterator for a list?

Is it possible to do the following?
List<String> list = new ArrayList<String>();
Iterator<String> iterator = list.listIterator();
populateList(list);
I am creating a list and getting its iterator before populating the list
with data. Will I be able to get the elements of the list using the
iterator? Does the order of getting the iterator and populating the array
make any difference?
Any help will be appreciated.

No comments:

Post a Comment