Bad operand types for binary operator

So I'm trying to make code generic and I'm coming across this problem, where I get an error that says bad operand types for binary operator.

Here is an example:

if(compare(data < root.data))

I get the error said above. Any hints on how to fix it?

I have this setup at the start of it:

class Node<T>
{
   T data;
   Node<T> left, right;

Node(T data)
    {
    this.data = data;
    }
}

Java doesn't support operator overloading, The < operator is define for primitive data types like(int,double..).

It is not defined for non-primitive types or user define types.

You should use the Comparable interface instead of <.

You call data < root.data but the operator < or other similar operators are only defined for primitive datatypes like int, long, double, float etc.

You can not call < on objects, in contrast to other languages which support operator overloading. However you can let the objects implement Comparable which provides a compareTo method that essentially does the same. You can call it like this:

data.compareTo(root.data);

and it returns a negative-, positive- or zero-value, based on if the first argument is less, greater or equal the second argument.