This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I needed a dynamic array so I did an ArrayList. My actual method needs to return a int array. SO in order to do that do I have to declare an in array of the size of my ArrayList and then get each element out convert it to an int and then put it into my int array or is there a way I can do it in one shot w/o a loop?
Or, assuming your ArrayList contains Integer objects, you can get a tiny bit further with
This way you have an Integer rather than an Object. But still, if what you really wanted was an int, you need a loop. And as long as you have to do that anyway, you might as well forget the toArray() stuff and build the array you want directly:
It would be nice if there were a one-liner for this, but it's not that big a deal really...
"I'm not back." - Bill Harding, Twister
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com