title: For each loop with array list return sorted array but changing an a array list with adding a value is not returned
body: <p>At first used for each loop to change the array list value by adding one ,next i created a tree map with array list as values and added foreach loop for sorting each array list but in the first case the values of arraylist not changed but in second it got sorted. why this happens</p>
  <pre><code>        
           Numbers.add(23);
           Numbers.add(32);
           Numbers.add(63);   
           Numbers.add(45);
          
          for(Integer list : Numbers) {
  
              list = list + 1;    
              
          }
          System.out.println(Numbers);
          //23 32 63 45
  
         Map&lt;Integer, ArrayList&lt;String&gt;&gt; map = new TreeMap&lt;&gt;();       
          ArrayList&lt;String&gt; mapValue = new ArrayList&lt;String&gt;();
          mapValue.add(&quot;48&quot;);
          mapValue.add(&quot;12&quot;);
          mapValue.add(&quot;24&quot;); 
          map.put(0,mapValue);
          
          ArrayList&lt;String&gt; mapValue2 = new ArrayList&lt;String&gt;();
          mapValue2.add(&quot;200&quot;);
          mapValue2.add(&quot;130&quot;);
          mapValue2.add(&quot;110&quot;);
          map.put(1,mapValue2);
          
          System.out.println(map);
          
          //{0=[48, 12, 24], 1=[200, 130, 110]}
  
          for(ArrayList&lt;String&gt; list : map.values()) {
              
              
              Collections.sort(list);
              
              
          }
          
          System.out.println(map);
         
          //{0=[12, 24, 48], 1=[110, 130, 200]}
  
  
  
  
  </code></pre>