java compare two values of diffrent classes
<p>Let's say I have an Animal class, and a cat and a dog class that extend from the animal class. 
Now I want to see if the dog and the cat have the same name.
I've tried this:</p>

<pre><code>if(kitty.getName().equals(doggy.getName()))
</code></pre>

<p>But it won't let me do this because a cat is not a dog I guess? Is there a way I can still compare? Or do I really not wanna do something like this, if so then why not?</p>