java hashmap array to double array
Posted
by
Tweety
on Stack Overflow
See other posts from Stack Overflow
or by Tweety
Published on 2011-01-12T02:40:05Z
Indexed on
2011/01/12
2:54 UTC
Read the original article
Hit count: 188
Hi,
I declared LinkedHashMap<String, float[]>
and now I want to convert float[]
values into double[][]
. I am using following code.
LinkedHashMap<String, float[]> fData;
double data[][] = null;
Iterator<String> iter = fData.keySet().iterator();
int i = 0;
while (iter.hasNext()) {
faName = iter.next();
tValue = fData.get(faName);
//data = new double[fData.size()][tValue.length];
for (int j = 0; j < tValue.length; j++) {
data[i][j] = tValue[j];
}
i++;
}
When I try to print data System.out.println(Arrays.deepToString(data));
it doesn't show the data :(
I tried to debug my code and i figured out that I have to initialize data outside the while loop but then I don't know the array dimensions :(
How to solve it?
Thanks
© Stack Overflow or respective owner