Is this a good way of writing contains method in Java? I want to check if the structure that I use contains an object. To do so I wrote the following contains method:

boolean contains(Topic t){
        if (t == null)
            return false;
        if (t.equals(root))
            return true;
        else
            return false;
    }


Is this a good way of writing? Is it better to write:

boolean contains(Topic t){
        if (t == null)
            return false;
        if (t.x == root.x &amp;&amp; t.y == root.y)
            return true;
        else
            return false;
    }
Neither is best. The best would be:
boolean contains(Topic t){
    return t != null &amp;&amp; t.equals(root);
}

Using equals is better than using the properties of Topic, because of Single Responsibility Principle
If that was too fast for you:
Step 1:
if (t.x == root.x &amp;&amp; t.y == root.y)

Using t.equals(root) is better. It is likely that you want to do this comparison in more than one method between two variables of Topic, in which case you don't want to duplicate code.
Step 2:
if (condition)
    return true;
else
    return false;

condition is a boolean. You return a boolean. You might as well just return condition directly.
Now, using single-line if-statements without braces can lead to bugs when you suddenly introduce a new line without remembering to add braces. Apple has done this mistake, and so can you.
With the steps taken so far we have:
boolean contains(Topic t) {
    if (t == null) {
        return false;
    }
    return t.equals(root);
}

Final step:
Use boolean short-circuiting &amp;&amp; operator to return in only one line, while still having it readable (at least readable for those who are somewhat experienced with boolean logic, which most programmers hopefully are)
So again, the best version:
boolean contains(Topic t) {
    return t != null &amp;&amp; t.equals(root);
}