인터페이스 MyThing의 목록 인 인터페이스 MyList를 정의하려고합니다. MyList의 의미 중 일부는 MyThing 인터페이스를 구현하지 않는 객체에서 해당 작업이 의미가 없음을 의미합니다.일반 인터페이스 : 특정 항목의 목록
올바른 선언인가요?
interface MyList<E extends MyThing> extends List<E> { ... }
편집 : 지금은 그 방법 중 하나로서으로 myList를 반환하는 또 다른 인터페이스를 가지고 (2 부).
// I'm defining this interface
// it looks like it needs a wildcard or template parameter
interface MyPlace {
MyList getThings();
}
// A sample implementation of this interface
class SpecificPlace<E extends MyThing> implements MyPlace {
MyList<E> getThings();
}
// maybe someone else wants to do the following
// it's a class that is specific to a MyNeatThing which is
// a subclass of MyThing
class SuperNeatoPlace<E extends MyNeatThing> implements MyPlace {
MyList<E> getThings();
// problem?
// this E makes the getThings() signature different, doesn't it?
}
잠깐 기다려 주시겠습니까? 목록은 소비자가 되었기 때문에 우리는 수퍼를 사용해야 했습니까? – willcodejavaforfood
클래스 형식 매개 변수 선언에 super를 사용할 수 없으므로 응답을 알아 내지 못하게됩니다. ;) –
잘 모르겠지만 두 가지 문제를 혼동스럽게 생각합니다. 나는 네가 SomeClass을 본 적이 있다고 생각하지 않는다. SomeClass 이 타입이 메소드 인자를 지정하는데 사용될 때. http://www.ibm.com/developerworks/java/library/j-jtp07018.html –