• Post Reply Bookmark Topic Watch Topic
  • New Topic

Foo[][] population  RSS feed

 
Walsh graham
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im writing a function thats returning a N dimensional array and I'm doing it wrong.. I know there's a better way to do it;

Here's what I'm doing now (and I know its filthy)

foo[][] getIt()
{

List fooList= new ArrayList();

// assume someOtherFooList is a list containing foo[]'s
// i.e. ita list of array's of foos
// And no, I cannot just create a foo[][] from the someOtherFooList, I've simplified the logic to
// get the right answer to my question

for (int i =0; i<someOtherFooList.size(); ++i)
{
fooList.add(someOtherFooList.get(i);
}

foo[][] retval = new foo[fooList.length];

for (int i2=0; i2 < fooList.length; ++i2)
{
foo[i2] = fooList.get(i2);
}

return retval;

}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although you say you can't turn "otherFooList" directly into an array, you surely can turn "fooList" into one directly:


 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't clear to me why you even need fooList at all. Despite your comment, why can't you just work with the orginal list directly?
 
hight low
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much for sharing the post.
Thanks for sharing this useful information. It's great.
document internet management software property asset project find the right internet management software for you document internet management software property asset project
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!