forked from bitcocom/JavaTPC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTPC37.java
More file actions
27 lines (25 loc) · 700 Bytes
/
TPC37.java
File metadata and controls
27 lines (25 loc) · 700 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
import java.util.ArrayList;
import kr.infrine.ObjectArray;
import kr.tpc.*;
public class TPC37 {
public static void main(String[] args) {
//ObjectArray arr=new ObjectArray(5);
ArrayList arr=new ArrayList(5); // Object[], 배열의 길이에 제약이 없다.
arr.add(new A());
arr.add(new B());
arr.add(new A());
arr.add(new A());
arr.add(new A());
arr.add(new A());
arr.add(new A());
arr.add(new A());
for(int i=0;i<arr.size();i++) {
Object o=arr.get(i);
if( o instanceof A) {
((A)o).go();
}else {
((B)o).go();
}
}
}
}