最简单的方法是将2d int数组转换为2d double [英] Shortest way to cast a 2d int array into 2d double
本文介绍了最简单的方法是将2d int数组转换为2d double的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个方法,它只能获得 int [] [] $ c>的
double [] []
$ c>,是有一个简单的方法,这样做在java中,简单的如:
int [] [] iArray = {
{1,2,},
{5,6,}
};
double [] [] dArray =(double [] [])iArray; ???不幸的是,投射你的数组的唯一方法是迭代(iterate),你可以使用这个方法来创建一个新的数组。通过每个元素并一个接一个地转换,同时在新的 double [] []
数组中重新插入。
没有捷径。
I have a method which only gets double[][]
to which I would like to pass int[][]
, is there a short way of doing this in java, something as simple as:
int [][] iArray = {
{ 1, 2, },
{ 5, 6, }
};
double [][] dArray = (double[][]) iArray ; ???
解决方案 Unfortunately the only way to cast your array is to iterate through each element and cast them one by one while re-inserting in your new double[][]
array.
There is no shortcut.
这篇关于最简单的方法是将2d int数组转换为2d double的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文