Possible Duplicate:
Java Overload method with inherited interface
I'm not positive my title is correct, but I'm sure I'll be corrected if it's not.
I'm trying to overload the helpIt method like so:
class Animal{}
class Dog extends Animal{}
class Foo implements AnimalHelper
{
@Override
public void helpAnAnimal( Animal a )
{
helpIt( a );
}
private void helpIt( Dog d )
{}
private void helpIt( Animal a )
{}
}
The problem is this never calls the helpIt( Dog d ) method, even when the animal is a Dog. I used this approach because the class Foo overrides the AnimalHelper's helpAnAnimal method.
Am i missing something here? I would hope i don't have to check instanceof and then cast it. I believe this worked out of the box in .Net, but that memory is a bit faded and possibly incorrect.