-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMailList.java
36 lines (29 loc) · 963 Bytes
/
MailList.java
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.LinkedList;
class Address {
private String name;
private String street;
private String city;
private String state;
private String code;
Address(String n, String s, String c, String st, String cd) {
name = n;
street = s;
city = c;
state = st;
code = cd;
}
public String toString() {
return name + "\n" + street + "\n" + city + " " + state + " " + code;
}
}
class MailList {
public static void main(String[] args) {
LinkedList<Address> ml = new LinkedList<Address>();
ml.add(new Address("J.W. West", "11 Oak Ave", "Urbana", "IL", "61801"));
ml.add(new Address("Ralph Baker", "1142 Maple Lane", "Mahomet", "IL", "61853"));
ml.add(new Address("Tom Carlton", "867 Elm St", "Champaign", "IL", "61820"));
for (Address element : ml)
System.out.println(element + "\n");
System.out.println();
}
}