有没有一种方法可以在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#中