• Post Reply Bookmark Topic Watch Topic
  • New Topic

2d arrays  RSS feed

 
Stephen ODonnell
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a vector which i convert to an array of objects as follows:
Vector vctNumbers = (Vector)vctGraphItems.elementAt(1);
Object objArr[] = vctNumbers.toArray(); //array of objects
I now need to convert this 1-d Object array, to a 2-d float array:
float[][] array = ...
If anyone has done this before or can explain this to me i would be very greatful.
thanks,
Stephen O Donnell
 
Nathanael Ulrick
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming the Objects are actually Floats you would need a nested loop which copies the values one by one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!