-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollectionInJava.java
More file actions
56 lines (27 loc) · 869 Bytes
/
Copy pathCollectionInJava.java
File metadata and controls
56 lines (27 loc) · 869 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
class course{
String courseName;
public course(String courseName) {
this.courseName = courseName;
}
public String toString() {
return courseName;
}
}
class Interface{
public static void main(String [] args) {
List<course> courseName= new LinkedList<>();
courseName.add(new course("java"));
courseName.add(new course("Hibernate"));
courseName.add(new course("Spring boot"));
//accessing the value of the list using iterator
Iterator<course> courseIterator = courseName.iterator();
System.out.println("inside the iterator");
while (courseIterator.hasNext()) {
course c = courseIterator.next();
System.out.println(c);
}
}
}