[英]How to fix "type argument S is not within bounds of type-variable E" in Java
[英]Java generics type argument Project is not within bounds of type-variable E
我遇到了Java泛型的麻烦,这些泛型不允许我初始化AVLTree变量。
AVLTree类:
public class AVLTree<E extends Comparable<E>> extends BSTTree<E> {...}
BSTTree类和节点:
public class BSTTree<E extends Comparable<E>> {...
protected static class Node<E extends Comparable<E>> implements Comparable<Node<E>>{...}}
项目类别:
public class Project {
private String title;
public Project(String title){
this.title=title;
}
}
当我尝试执行以下操作时:
private AVLTree<Project> projectTree;
我收到这样的错误消息:
type argument Project is not within bounds of type-variable E where E is a type variable:
E extends Comparable<E> declared in class AVLTree
我究竟做错了什么?
尝试这样:
public class Project implements Comparable<Project> {
[add CompareTo method]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.