java - 运算符 <= 不能应用于“E”、“E”、泛型类
问题描述
我想合并到 JAVA 中的两个linkedLists,但是当我想比较数据h1.data <= h2.data
时,我得到那个运算符<=
不能应用于'E'
'E'
。
这是我的通用类SLLNode<E>
public class SLL<E extends Comparable<E>> {
private SLLNode<E> first;
public SLL(){
this.first=null;
}
现在当我想实现该merge
方法时
public SLLNode<E> merge (SLLNode<E> h1, SLLNode<E> h2){
if (h1 == null)
{
return h2;
}
if (h2 == null){
return h1;
}
SLLNode<E> mergedHead = null;
if(h1.data<=h2.data)
我收到上面列出的错误。
解决方案
推荐阅读
- json - Riot Api - 我怎样才能把其他地区的用户数据带进来?
- oracle - 有什么方法可以在每次执行之前清除 sql developer 中的 dbms_output 吗?
- electron - Electron-builder 制作不可行的软件包(ubuntu)
- java - 如何点击simpleAdapter listview改变fragment并获取数据?
- apache-flink - Flink:将事件附加到有限数据流的末尾
- arangodb - 我可以过滤多个集合吗?
- amazon-web-services - 使用 Troposphere 在 cloudformation 模板中配置 WAF(Web 应用程序防火墙)
- typescript - 401 角度 6 中未经授权
- web-services - 在网站/服务中处理 oauth 令牌
- swift4 - 如何在一个名字中获得所有中间名