I want to merge to two linkedLists in JAVA but when i want to compare the data h1.data <= h2.data
, I am getting that operator <=
cannot be applied to 'E'
'E'
.
Here is my generic class SLLNode<E>
public class SLL<E extends Comparable<E>> {
private SLLNode<E> first;
public SLL(){
this.first=null;
}
Now when I want to implement the merge
method
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)
I'm getting the error listed above.