title: how jvm handles creating object inside a loop
body: <pre><code>List list = new ArrayList();
  
  
  String[] test = {"ram", "mohan", "anil", "mukesh", "mittal"};
  
  for(int i =0; i &lt; test.length; i++)
  
  {
  
    A a = new A();
  
    a.setName(test[i]);
  
    list.add(a);
  
  }
  </code></pre>
  
  <p>How JVM handles creation of object a in each loop? How "list" differntiate between different instance? Is it good practice to create object on each iteration. If no, what is the best solution for adding object into a list.</p>