title: Output of List varies while using loops on Varargs
body: <p>Outputs of the code is varies on iterating with Varargs.
  Please let me know what is the reason for different outputs.</p>
  <pre><code>public class Demo {
  
      public static void main(String[] args) {
          
          Integer[] a = new Integer[]{1, 2, 3};
          Integer[] b = new Integer[]{4, 5, 6};
          
          
          List&lt;Object&gt; list1=new ArrayList&lt;&gt;();
          addAllObj1(list1, a,b);
          System.out.println(list1); //[[Ljava.lang.Integer;@24d46ca6, [Ljava.lang.Integer;@4517d9a3]
          
          List&lt;Object&gt; list2=new ArrayList&lt;&gt;();
          addAllObj2(list2, a,b);
          System.out.println(list2); //[1, 2, 3, 4, 5, 6]
      }
      
      private static void addAllObj1(List&lt;Object&gt; list, Object[]... arr) {
          for(Object o:arr) {
              Collections.addAll(list, o);
          }
      }
      
      private static void addAllObj2(List&lt;Object&gt; list, Object[]... arr) {
          Collections.addAll(list, arr[0]);
          Collections.addAll(list, arr[1]);
      }
  
  }
  </code></pre>
  <p>Thanks for your Help!</p>