title: Spark DataFrame - select list of columns using Java API
body: <p>I'm trying to select List of columns from the DataFrame using Java API.</p>
  
  <p><strong>Sample Java Code:</strong></p>
  
  <pre class="lang-java prettyprint-override"><code>List&lt;String&gt; colList = Arrays.asList(new String[] { "column1", "column2", "column3" });
  df.selectExpr((String[])colList.toArray()).show();
  </code></pre>
  
  <p>In Java API, I have to use <code>selectExpr</code> instead of <code>select</code>. Is there any other way of selecting list of columns using Java API.</p>
  
  <p>But in Scala, I can do something like below.</p>
  
  <p><strong>Sample Scala Code:</strong></p>
  
  <pre class="lang-scala prettyprint-override"><code>val colList = List("column1", "column2", "column3")
  df.select(colList.head, colList.tail: _*).show
  </code></pre>