automatic object naming java
<p>I new to java and I have been trying to code a method that allow me to create and declare an object and add it to my array list automatically.</p>

<pre><code>public static void 

public static int objectCreate(String a, ArrayList&lt;pet&gt; list,int x)
{
pet pets= new pet ("pet"+ x);
pet pets.getName() = new pet("dog",10,"healthy");
list.add(pet.getName());
x++;
return x
}
</code></pre>

<p>String a is the pet's name and i'm trying to make it so that everytime i call this method, it will create an object with a different name. For instance, the second time i call this name, it would create an object called pet2 and so on and so forth. Is there a way to achieve this?</p>
