-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava178_Vector.java
More file actions
50 lines (38 loc) · 812 Bytes
/
Copy pathJava178_Vector.java
File metadata and controls
50 lines (38 loc) · 812 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
package java0911_collection;
import java.util.Vector;
/*
* 홍길동 30
* 이영희 25
*/
class Person {
String name;
int age;
public Person() {
super();
}
public Person(String name, int age) {
super();
this.name = name;
this.age = age;
}
@Override
public String toString() {
return name + " " + age;
}
}
public class Java178_Vector {
public static void main(String[] args) {
/*
* Person arr[] = new Person[2]; arr[0] = new Person("홍길동", 30); arr[1] = new
* Person("이영희", 25);
*
* for (Person ps : arr) { System.out.printf("%s \n", ps.toString()); }
*/
Vector<Person> vt = new Vector<Person>();
vt.add(new Person("홍길동", 30));
vt.add(new Person("이영희", 25));
for (Person ps : vt) {
System.out.println(ps.toString());
}
}
}