Skip to content

Commit f03d588

Browse files
authored
Create Box.java
1 parent 5f265e2 commit f03d588

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Box.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package kr.ac.kookmin.cs.opp.ch5;
2+
3+
public class Box<T> {
4+
private T type;
5+
6+
public T getype( ) {
7+
return type;
8+
}
9+
public void setType(T type) {
10+
this.type = type;
11+
}
12+
13+
public static void main(String[] args) {
14+
Box<String> boxString = new Box<String>(); // <> 변수타입을 마음대로 바꿀수 있따. 별거 없다.
15+
Box<Integer> boxInteger = new Box<Integer>(); // <> 변수는 반드시 참조형 변수값만 가능하다
16+
17+
boxString.setType("String generic");
18+
boxInteger.setType(123);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)