title: Difference between Arrays.fill() and a for loop for initializing Array of linkedlist
body: <p>why this gives different output.</p>
  
  <pre><code>LinkedList&lt;Integer&gt; blocked [] = new LinkedList[n+1];
  int obstacles [][]= {{5, 5},{4 ,2},{2 ,3}};
  
  CASE 1: Arrays.fill(blocked, new LinkedList&lt;Integer&gt;());
  System.out.println(blocked);  
  
  OUTPUT :  
  [5, 2, 3]
  [5, 2, 3]
  [5, 2, 3]
  [5, 2, 3]
  [5, 2, 3]
  
  CASE 2:  for(int i=0;i&lt;=n;i++)
           blocked[i]= new LinkedList&lt;Integer&gt;();
  OUTPUT : []
           [3]
           []
           [2]
           [5]
  </code></pre>
  
  <p>why this is working differently , is using new linkedlist in arrays.fill is sending same object reference?                                                                                      </p>