반응형 java generic1 Java Generics Class generic type ClassGenericType classGenericType = new ClassGenericType(); /** * 클래스 내에 타입이 선언되어야 한다 * */ class ClassGenericType { // static 필드는 제너릭 타입을 가질 수 없다 // private static T t; private T t; public void set(T t) { this.t = t; } public T get() { return t; } } Interface generic type /** * 는 abstract method의 제너릭 타입을 다르게 주고 싶을 때 사용 이런식으로 사용 */ interface InterfaceGenericType { T1 doSomethin.. 2022. 2. 25. 이전 1 다음 반응형