Q:

How do I check for the following instanceof in Java?

I'm looking for a better way to do the following:
class Animal {}

class Dog extends Animal
class Cat extends Animal
class Rat extends Animal
class Bat extends Animal
.. 50 such animals

Now I have a list of animals - List<Animal>.
I want to do something like this:
for (Animal animal : animalList) {
   if (animal instanceof (Dog or Cat or 1 of 10 such animals) ) {
      //do something with animal.
   }
}

What is a good way to check wither this animal is an instance of a sublist if animals besides doing 10 instanceof checks?

A:

Expanding on Rogue's comment:
Have Animal methods to differentiate subclasses like for example
Animal.isMammal()
or Animal.hasFourLegs()
Then the subclasses have properties like Dog.isMammal = true
or Bat.hasFourLegs = false

