0
java iterators: the first tasks
My opinion that the first question in not clear!! Look at a code: What is the output of this code? List<Integer> list = new ArrayList<Integer>(); list.add(10); list.add(20); list.add(30); Iterator<Integer> it = list.iterator(); it.next(); System.out.println(it.next()); !! this is the properly: What is the output of this code? ArrayList<Integer> list = new ArrayList<Integer>(); list.add(10); ...........
10 Respuestas
+ 6
List<Integer> list = new ArrayList<Integer>();
list.add(10);
list.add(20);
list.add(30);
Iterator<Integer> it = list.iterator();
it.next();
System.out.println(it.next());
//output 20
+ 1
20
+ 1
The output is 20
+ 1
The output of the code is 20.
+ 1
20
0
ok, but the code in this sample return error :)
0
this is the code, but look at the simple in the "?" for "Iterators" section ...
import java.util.Iterator;
import java.util.ArrayList;
public class MyClass {
public static void main(String[ ] args) {
List<Integer> list = new ArrayList<Integer>();
list.add(10);
list.add(20);
list.add(30);
Iterator<Integer> it = list.iterator();
it.next();
System.out.println(it.next());
}
}
}
0
thank you!
0
I think it should have an error..According to my knowledge the correct answer is 10.
0
Yes