
At once, I am memorizing that source.
after that, I can code something I want.
I am willing to memorize other source, cuz base is essential for me.
class Box //타입 매개 변수
{
T content;
Box(T content)
{
this.content = content;
}
T getContent()
{
return content;
}
}
public class Main
{
public static void main(String[] args)
{
//객체를 생성할때 타입을 정합니다.
//기본 자료형은 래퍼클래스를 사용하여 지네릭 인자로 전달해야 함
//지네릭을 통해서 box는 어떤 자료형의 데이터도 담을 수 있음(유연성)
Box stringBox = new Box<>("Hello");
System.out.println("내용물"+stringBox.getContent());
Box<Integer> numberBox = new Box<>(999);
System.out.println("내용물"+numberBox.getContent());
Box<Boolean> boolBox = new Box<>(true);
System.out.println("내용물"+boolBox.getContent());
}
}