C graphics C graphics - 1 year ago 106
Java Question

Shortest way to cast a 2d int array into 2d double

I have a method which only gets

to which I would like to pass
, is there a short way of doing this in java, something as simple as:

int [][] iArray = {
{ 1, 2, },
{ 5, 6, }
double [][] dArray = (double[][]) iArray ; ???

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download