title: How to convert collection of strings to string array in java
body: <p>I am trying to pass <code>attributeNames</code> which is a <code>collection of string</code> to a method <code>setColumnNames</code> that accepts <code>string array</code>.</p>
  
  <pre><code>public Map&lt;String, String&gt; getAttributes(String rowKey, Collection&lt;String&gt; attributeNames, String columnFamily) {
  
      try {
  
          SliceQuery&lt;String, String, String&gt; query = HFactory.createSliceQuery(keyspace, StringSerializer.get(), StringSerializer.get(), StringSerializer.get()).
                  setKey(rowKey).setColumnFamily(columnFamily).setColumnNames(attributeNames);
  
      } catch (HectorException e) {
          LOG.error("Exception in CassandraHectorClient::getAttributes " +e+ ", RowKey = " +rowKey+ ", Attribute Names = " +attributeNames);
      }
  
      return null;
     }
  </code></pre>
  
  <p>Definition for <code>setColumnNames</code></p>
  
  <pre><code>SliceQuery&lt;K, N, V&gt; setColumnNames(N... columnNames);
  </code></pre>
  
  <p>I am getting this exception everytime-</p>
  
  <pre><code>The method setColumnNames(String...) in the type SliceQuery&lt;String,String,String&gt; is not applicable for the arguments (Collection&lt;String&gt;)
  </code></pre>
  
  <p>How can I convert collection of strings to string array in Java? Any idea?</p>