package ch10.collection;
public class Phone {
private String name;
private String tel;
public Phone(String name, String tel) {
this.name=name;
this.tel=tel;
}
@Override
public String toString() {
return "Phone [name=" + name + ", tel=" + tel + "]";
}
}
package ch10.collection;
import java.util.ArrayList;
public class Ex04 {
public static void main(String[] args) {
Phone p=new Phone("서경진", "010-1234-5678");
Phone h=new Phone("나종성", "010-7894-4561");
Phone o=new Phone("김진영", "010-1597-3219");
ArrayList<Phone> list=new ArrayList<Phone>();
list.add(p);
list.add(h);
list.add(o);
System.out.println(list);
}
}
[Phone [name=서경진, tel=010-1234-5678], Phone [name=나종성, tel=010-7894-4561], Phone [name=김진영, tel=010-1597-3219]]