title: in java How to write code with memory management and CPU uses manage, in Collection java
body: <pre><code>public class MillionData {
  
      public static void main(String[] args) {
          List&lt;String&gt; str = new ArrayList&lt;String&gt;();
          for(double i= 0; i&lt;1000000000; i++) {
              str.add(""+i);
              if(i%10 ==0)
                  System.out.println(""+i);
          }
          System.out.println("done insertion of "+str.size());
  
      }
  
  }
  </code></pre>
  
  <p>while running this code CPU Uses reached to 100% and pc is getting stuck how to manage the application where we are inserting lots of data in list or any other Collection where we are storing lots of data but o/p stuck on 1.184349E7 and taking so much time to moving forward how to manage this kind of issue with coding or any other way most prefer to coding</p>