2012-06-18 41 views
0

我有一个包含12个数字的数组,我想将这12个数字保存在12个浮点数中。通常我应该如何执行此操作并将它们中的每一个保存在一个浮点数中?单独的数组数并将它们保存为浮点数

array numbers = { a,b,c,....} 
object1 = a; 
object2 = b; 
+0

http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html –

+0

告诉我们哪些类型数Ur数组包含的? –

回答

2
int[] numbers = { 1, 2, 3, 4, 5, ... }; 
float f1 = (float) numbers[0]; 
float f2 = (float) numbers[1]; 
... 
1
int[] numbers = { 1, 2, 3, 4, 5, 6 }; 

float[] num_floats = new float[numbers.length]; 

for (int i = 0; i < numbers.length; i++) 
{ 
    num_floats[i] = (float) numbers[i]; 
} 
相关问题