Generic Programming
제네릭 프로그래밍은 데이터 형식에 의존하지 않고 하나의 값이 여러
다른 데이터 타입들을 가질 수 있는 기술에 중점을 두어 재사용성을 높일 수 있는
프로그래밍 방식이다.
Generic한 변수/자료구조
Event ev;
Event []events = new Event[capacity];
Object obj;
Generic한 알고리즘(method)
Arrays.sort(shpes,0,n);
Generic한 클래스
Generics
예)
public class Box<T>{
private T t;
public void set(T t) {this.t = t;}
public T get() { return t;}
}
Box<Integer>Box = new Box<Integer>();
box.set(new Integer(10));
Integer a = box.get():
'알고리즘 with 자바 > 자료구조' 카테고리의 다른 글
| Generic 프로그래밍과 Generics 3 (0) | 2021.07.13 |
|---|---|
| Generic 프로그래밍과 Generics 2 (0) | 2021.07.13 |
| 추상클래스와 인터페이스 3 (0) | 2021.07.07 |
| 추상클래스와 인터페이스 2 (0) | 2021.07.07 |
| 추상클래스와 인터페이스 1 (0) | 2021.07.07 |