How are you? Let me explain. I have a program that creates animals, the class has its methods, variables, etc., and what I want to do is create objects with the same names but change a number in their instance, for example:
int cantidad = 2;
for(int i=0;i<cantidad;i++){
Animal perro+i = new Animal("perro"+Integer.toString(i));
}
which would be the same as this:
Animal perro0 = new Animal("perro0");
Animal perro1 = new Animal("perro1");
Animal perro2 = new Animal("perro2");
In my mind it would look like this, but the instance (I don't know if it's said like that) "dog+i" doesn't work, so I don't know how you can do something that creates my children that way, since this would save me too much work , because I must have 6 different species and each one with different amounts of creation, I hope I have explained myself well and thank you very much in advance for your help.
The only way you have to get this I think is like this
And then you can access your dogs like this
You could also use an array but it would have a fixed length