import java.util.ArrayList;
import java.util.Iterator;
public class hasnext {
public static void main(String[] args) {
String months[] = { "jan", "feb", "march", "april", "may", "june" };
ArrayList list = new ArrayList();
for (String m : months) {
list.add(m);
}
Iterator iterator = list.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
}
Output
jan feb march april may juneIf you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.