有沒有一種方法可以在Java中定義一個類似於下面的C#泛型constratint的泛型約束? class Class1<I,T> where I : Interface1, Class2 : I
我試圖做這樣的: class Class1<I extends Interface1, T extends I & Class2>
但是,編譯器會抱怨的「等級2」的部分:類型參數不能其次是其他界限
我想指定一個約束,這是一個泛型參數的另一種類型。 class KeyFrame<T>
{
public float Time;
public T Value;
}
// I want any kind of Keyframe to be accepted
class Timeline<T> where T : Keyframe<*>
{
}
但是這不能在c#中