How to pass an array to an array with another primitive type

Can someone execute the code in a simple way?

float[] floats = {...}; // create an array
// Now I want to create a new array of ints from the arrays floats
int[] ints = ????;

I know that I can just put an element by element into a new array. But is it possible easier?

thank

+3
source share
2 answers

I am pretty sure that you cannot do this in a different way for your float, for example, than by individually listing each element.

I quickly figured it out, which attracted someone with a similar problem that more or less confirms what I said:

http://www.java-forums.org/advanced-java/11255-type-casting-array.html

. . " ", , .

+4

. , , -, float, getter int.

, , .

0

Source: https://habr.com/ru/post/1741141/


All Articles