Given the following class for persisting objects into database ....
I'm using the following main class to create the objects to be saved into database ....
Notice in the "Persisting single animal" section, I'm passing over an object of the Animal type into the function which takes a variable of Object type? This works.
Notice in the "Persisting a list of animals" section, I'm passing a List object of the Object type into the function which takes a variable of Object type? This works also. But the reason why I'm passing a List<Object> rather than a List<Animals> is because if I use List<Animals> I'll get the following error.
error: incompatible types: List<Animals> cannot be converted to List<Object>
This is being reported on the following line.
So why it works for a single object but not for a List of objects?