我正在尝试将一个字符串集合
attributeNames
传递给一个接受字符串数组
的方法 setColumnNames
。
public Map<String, String> getAttributes(String rowKey, Collection<String> attributeNames, String columnFamily) {
try {
SliceQuery<String, String, String> 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;
}
Definition for setColumnNames
SliceQuery<K, N, V> setColumnNames(N... columnNames);
我每次都遇到这个异常 -
The method setColumnNames(String...) in the type SliceQuery<String,String,String> is not applicable for the arguments (Collection<String>)
我该如何在Java中将字符串集合转换为字符串数组?有什么想法吗?
toArray()
不也适用于 Collections(而不仅仅是 Lists)吗? - vikingsteve