あなたがStorage
を定義しながら、あなたはまだ方法find
を定義(およびそれを使用していない)されているので、同じ署名をしてください:
Storage implements IStorage {
<T extends ICommon> Collection<T> find(String name, boolean isExact) {
//some code
}
}
を、あなたが実際にそのジェネリックメソッドを呼び出すときは、コンクリートの型パラメータを指定します。
をあなたは、あなたの一般的な方法で
<T extends ICommon>
で導入
Storage s = new Storage();
s.<IOrganization>find("hello world", true);
しかし、パラメータの型T
を使用すると、パラメータリストに持っていないので、役に立ちません。
一般的な方法ではありません。しかし、何かが次のように:
interface IStorage {
public Collection<? extends ICommon> find(String name, boolean isExact);
}
//and
class Storage implements IStorage {
public Collection<IOrganization> find(String name, boolean isExact) {
//some code
}
}
//or
class Storage implements IStorage {
public Collection<? extends ICommon> find(String name, boolean isExact) {
//some code
}
}
である。ジェネリックインターフェイスを作成するのは妥当です。 –