-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIteratorAdd.java
More file actions
39 lines (31 loc) · 866 Bytes
/
IteratorAdd.java
File metadata and controls
39 lines (31 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.*;
public class IteratorAdd
{
public static void main(String[] Soylu)
{
ArrayList<String> list=new ArrayList<>();
list.add("polat");
list.add("memati");
list.add("abduley");
ListIterator <String>itr=list.listIterator();//bir nevi pointer atıyormuşuz gibi düşünelim
itr.add("elif");
System.out.println(itr.previous());
System.out.println();
while(itr.hasNext())
System.out.println(itr.next());
System.out.println();
ListIterator<String> itr2=list.listIterator();
itr2.next();
itr2.set(itr.previous());
while(itr2.hasPrevious())
System.out.println(itr2.previous());
}
}
/* Output
elif
elif
polat
memati
abduley
abduley
*/