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); ...........

18th Nov 2017, 8:39 AM
Radostina Stefanova
Radostina Stefanova - avatar
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
16th Dec 2018, 8:03 PM
Likhon
Likhon - avatar
+ 1
20
16th Sep 2019, 6:59 AM
PRATIK NAVALE
+ 1
The output is 20
11th Mar 2021, 5:37 PM
Rusz Tamás
Rusz Tamás - avatar
+ 1
The output of the code is 20.
18th Oct 2021, 3:25 AM
chanchal mittal
chanchal mittal - avatar
+ 1
20
1st Jan 2022, 12:23 PM
M.I.M.Aqueel
M.I.M.Aqueel - avatar
0
ok, but the code in this sample return error :)
19th Nov 2017, 8:00 AM
Radostina Stefanova
Radostina Stefanova - avatar
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()); } } }
19th Nov 2017, 8:17 PM
Radostina Stefanova
Radostina Stefanova - avatar
0
thank you!
19th Nov 2017, 8:51 PM
Radostina Stefanova
Radostina Stefanova - avatar
0
I think it should have an error..According to my knowledge the correct answer is 10.
7th Apr 2020, 3:47 AM
Hasini Uththara
0
Yes
6th Oct 2021, 11:27 AM
Dipesh Yadav
Dipesh Yadav - avatar