list.add java

Say I have a List like:

List list = new ArrayList[]; list.add["a"]; list.add["h"]; list.add["f"]; list.add["s"];

While iterating through this list I want to add an element at the end of the list. But I don't want to iterate through the newly added elements that is I want to iterate up to the initial size of the list.

for [String s : list] /* Here I want to add new element if needed while iterating */

Can anybody suggest me how can I do this?

0

Video liên quan

Chủ Đề