The document contains a worksheet with code snippets that demonstrate the use of iterators in Java. It asks for the output of various blocks of code involving ArrayLists and iterators, including adding, removing, and modifying elements. Each question requires the reader to analyze the code and predict the resulting output.
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
2 views
Iterator Worksheet1 Java Aplus
The document contains a worksheet with code snippets that demonstrate the use of iterators in Java. It asks for the output of various blocks of code involving ArrayLists and iterators, including adding, removing, and modifying elements. Each question requires the reader to analyze the code and predict the resulting output.
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1
Name : ___________________________ Date : _________________
A+ Iterator Worksheet
Show the output of each block of code below.
1. What is output by the code at right?
ArrayList<Integer> x = new ArrayList<Integer>(); x.add(11); x.add(9); Iterator<Integer> it = x.iterator(); System.out.println(it.next()); System.out.println(it.next());
2. What is output by the code at right? ArrayList<Integer> w = new ArrayList<Integer>();