I've got 2 enum classes:
public enum Dogs
{
JACKIE("Jackie"),
BOBBY("Bobby");
}
and
public enum Cats
{
CHAN("Chan"),
SPONGE("Sponge");
}
And now I have a method in some other class where I want to pass enum as a parameter, so I could select either of them as per my needs.
public void findAnimal()
{
List<Dogs> animals = Arrays.asList(Dogs.values());
for (Dogs animal: animals)
{
rest of the code goes here
}
}
So instead of providing hardcoded 'Dogs' I want to have a choice and pass parameter to the method, something like
public void (Enum enumAnimals)
{
List<Enum> animals = Arrays.asList(Enum.values());
for (Enum animal: animals)
}
But it doesnt accept it like this. Is it possible to pass generic type as "Enum'?