我在.net c上使用java重写代码#面对带有通配符的传输类问题。有两个班级
public abstract class Client <T extends Connection <? >>
public class Connection <T extends Client <? >>
我以为我们可以这样做
public abstract class Client <T> where Connection <U>
但事实证明即使在这里也行不通了
public abstract class Client <T, U> where Connection <T, U>
public abstract class Connection <T, U> where Client <T, U>
那么如何摆脱这种局面呢?
答案 0 :(得分:2)
您可以执行以下操作:
public class Connection<T>
{
}
public abstract class Client<T, U> where T : Connection<U>
{
}