それは初心者の質問かもしれませんが、私はJavaを学んでおり、次のような定義を持つインターフェースに出くわしました:
public interface MyClass <T extends Comparable<T>>
誰かがそれが何を意味するのか説明してもらえますか? つまり、どのようなインターフェイスが作成されるかということです。
It means that the generic type argument must implement the Comparable interface.
When specifying <T extends Comparable<T>> you can use e.g. Collections.sort in this interface on type T. Without extends you can not guarantee that T is comparable.
Numbers and String are e.g. comparable and implement the Comparable interface.
The interface takes a type T which is Comparable with other T.
The interface is much the same only its generic type is constrained.
これは、T が同じオブジェクトに対して Comparable を実装する必要があることを意味します。
例えば
public interface MyClass <T extends Comparable<T>>
ja その後、次のように使用できます
public class MyImpl implements MyClass<String>
String は Comparable を実装しているため有効です。ただし、MyNewImpl は Comparable を実装していないため、次の文は有効ではありません。
public class MyNewImpl {}
public class MyImplTwo implements MyClass<MyNewImpl>
よろしくイグナシオ