<分区>
我正在尝试将 attributeNames
这是一个 字符串集合
传递给一个方法 setColumnNames
接受 string array
.
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;
}
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 中将字符串集合转换为字符串数组?有什么想法吗?