Java array assignment (multiple values)
Posted
by Danny King
on Stack Overflow
See other posts from Stack Overflow
or by Danny King
Published on 2010-04-04T21:59:17Z
Indexed on
2010/04/04
22:03 UTC
Read the original article
Hit count: 285
java
|variable-assignment
Hello,
I have a Java array defined already e.g.
float[] values = new float[3];
I would like to do something like this further on in the code:
values = {0.1f, 0.2f, 0.3f};
But that gives me a compile error. Is there a nicer way to define multiple values at once, rather than doing this?:
values[0] = 0.1f;
values[1] = 0.2f;
values[2] = 0.3f;
Thanks!
© Stack Overflow or respective owner