title: Java unchecked: unchecked generic array creation for varargs parameter
body: <p>I have set Netbeans to show unchecked warnings in my Java code, but I am failing to understand the error on the following lines:</p>
  
  <pre><code>private List&lt;String&gt; cocNumbers;
  private List&lt;String&gt; vatNumbers;
  private List&lt;String&gt; ibans;
  private List&lt;String&gt; banks;
  ...
  List&lt;List&lt;String&gt;&gt; combinations = Utils.createCombinations(cocNumbers, vatNumbers, ibans);
  </code></pre>
  
  <p>Gives:</p>
  
  <p><code>[unchecked] unchecked generic array creation for varargs parameter of type List&lt;String&gt;[]</code></p>
  
  <p>Method source:</p>
  
  <pre><code>/**
   * Returns a list of all possible combinations of the entered array of lists.
   *
   * Example: [["A", "B"], ["0", "1", "2"]]
   * Returns: [["A", "0"], ["A", "1"], ["A", "2"], ["B", "0"], ["B", "1"], ["B", "2"]]
   *
   * @param &lt;T&gt; The type parameter
   * @param elements An array of lists
   * @return All possible combinations of the entered lists
   */
  public static &lt;T&gt; List&lt;List&lt;T&gt;&gt; createCombinations(List&lt;T&gt;... elements) {
      List&lt;List&lt;T&gt;&gt; returnLists = new ArrayList&lt;&gt;();
  
      int[] indices = new int[elements.length];
      for (int i = 0; i &lt; indices.length; i++) {
          indices[i] = 0;
      }
  
      returnLists.add(generateCombination(indices, elements));
      while (returnLists.size() &lt; countCombinations(elements)) {
          gotoNextIndex(indices, elements);
          returnLists.add(generateCombination(indices, elements));
      }
  
      return returnLists;
  }
  </code></pre>
  
  <p>What is exactly going wrong and how would I fix it, as I suppose leaving unchecked warnings in the code is not a good idea?</p>
  
  <p><em>Forgot to mention, but I am using Java 7.</em></p>
  
  <p><strong>Edit</strong>: Also I see now that the method has the following:</p>
  
  <pre><code>[unchecked] Possible heap pollution from parameterized vararg type List&lt;T&gt;
    where T is a type-variable:
      T extends Object declared in method &lt;T&gt;createCombinations(List&lt;T&gt;...)
  </code></pre>