<p>in 5 steps to a 5, on AB practice test 1, question 34, i seroiuslly think the book is wrong. here’s what it says</p>
<p>LinkedList data = <filled with=“” data=“” via=“” some=“” method=“”>;
Iterator it = data.iterator();
for(int pos = 0; pos < data.size()-1; pos++)
{
Object thisItem = it.next();
if(thisItem.equals(it.next())
System.out.println(it.next() + “was found in consecutive positions.”);
}
}</filled></p>
<p>Which of the following best describes when an error will occur?
A. always
B. whenever the list is nonempty
C. whenever the list size is a multiple of 3
D. depends on the actual data in the LinkedList
E. no exception</p>
<p>I say B because if you have the LinkedList { 1,2,3,4,5,6,7,8,9}, then during the first iteration of the for loop, it will compare 1 and 2. BUT, during the 2nd iteration of the loop, it will compare 3 and 4 rather than 2 and 3. so i say that its not comparing 2 and 3 to see if they’re equal, so i but B. the book says D on the basis that the iterator moves forward one too many ONLY times when you have do have consecutive terms, but i have just shown that it moves too much even without consecutive terms.</p>
<p>can anybody help me figure this out?</p>