Casting of an arrays (float to int)

Hi,I have an array with float numbers. How can cast it to array of integer numbers?This casting DOES NOT workoverflowData=(int[]) overflowDataTemp;where overflowDataTemp has float[] structure.Thank you!
[277 byte] By [mustheroa] at [2007-11-27 8:11:38]
# 1

> Hi,

> I have an array with float numbers. How can cast it

> to array of integer numbers?

>

> This casting DOES NOT work

> > overflowData=(int[]) overflowDataTemp;

>

> where overflowDataTemp has float[] structure.

>

> Thank you!

Create a new array of ints and cast each array element to an int.

int[] newInts = new int[ overflowDataTemp.length ];

for ( int i = 0; i < overflowDataTemp.length; i++ )

{

newInts[ i ] = (int)overflowDataTemp[ i ];

}

bryanoa at 2007-7-12 19:55:44 > top of Java-index,Java Essentials,New To Java...
# 2
Is there the short way to do the same?
mustheroa at 2007-7-12 19:55:44 > top of Java-index,Java Essentials,New To Java...
# 3
> Is there the short way to do the same?It's only three lines, that's too long for you?
hunter9000a at 2007-7-12 19:55:44 > top of Java-index,Java Essentials,New To Java...
# 4
> > Is there the short way to do the same?> > It's only three lines, that's too long for you?For such simple procedure I think it's long enough.
mustheroa at 2007-7-12 19:55:44 > top of Java-index,Java Essentials,New To Java...
# 5
Do you want Java to cook your dinner and wash your car too?
floundera at 2007-7-12 19:55:44 > top of Java-index,Java Essentials,New To Java...