title: Converting List to Two dimensional array Java for TestNG data provider
body: <p>If you are using TestNG you would find that to use a method as a data provider you have to create a method that returns a two dimensional Object array.</p>
  
  <p>So if I have a List of (say) Students , is there any utility method to convert it into a two dimensional array.</p>
  
  <p>I am <strong>NOT</strong> looking to convert it manually using a loop like this</p>
  
  <pre><code> List&lt;Student&gt; studentList = getStudentList();
  
   Object [][] objArray = new Object[studentList.size][];
  
   for(int i=0;i&lt; studentList.size();i++){
      objArray[i] = new Object[1];
      objArray[i][0] = studentList.get(i);
   } 
  
   return objArray;
  </code></pre>
  
  <p>Instead I am looking at a utility function if any is available in any of the libraries.</p>
  
  <p>Or a better way of writing a data provider method for TestNG</p>