-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestList.java
More file actions
36 lines (33 loc) · 865 Bytes
/
TestList.java
File metadata and controls
36 lines (33 loc) · 865 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
import java.util.*;
class TestList {
public static void main(String[] args){
//List<Photo> album = new ArrayList<>();
List<Photo> album = new LinkedList<>();
album.add( new Photo("one",new Date(), "classroom"));
album.add( new Photo("two",new Date(), "library"));
album.add( new Photo("three",new Date(), "gym"));
album.add( new Photo("three",new Date(), "dorm"));
Iterator<Photo> iterator = album.iterator();
while(iterator.hasNext()){
Photo photo = iterator.next();
System.out.println( photo.toString() );
}
for( Photo photo : album ){
System.out.println( photo );
}
}
}
class Photo {
String title;
Date date;
String memo;
Photo(String title, Date date, String memo){
this.title = title;
this.date = date;
this.memo = memo;
}
@Override
public String toString(){
return title + "(" + date + ")" + memo;
}
}