java将double[]转换为long[]
正如标题所说,我必须将double[]
转换为long[]
,但我不知道该怎么做
我试试这个:
double[] ids = getIds(); // The ids I'm getting return in double format
List<Long> myArray = new ArrayList<Long>();
for (double _ids : ids) {
myArray.add((long)_ids);
}
System.out.println(myArray); // Works! the list is now long, I can print also in myArray.toArray()
// Now I need pass this on a long[] array for the system wich request the data
// Receive "getStringsById(String string, long... Ids)"
我真的很感谢你的帮助
谢谢你抽出时间
# 1 楼答案
创建一个
long[]
,而不是创建一个List<Long>
,后者需要调用toArray()
来获取一个long[]