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 tried your code and it didn't compile - so can't explain how you get a null pointer exception
Don't think (obj) a.toArray() makes sense - what do you expect it to do ?
obj = a.toArray() works fine in code below (have replaced object with Strings just for simplicity in example)
[ October 06, 2007: Message edited by: michael warren ]
Joined: Jul 25, 2005
I am trying to get array of objects from ArrayList into Objects array. I have just written a sample code. I am using arrayList because I don't know the size of array when I define array for Object. After collecting all objects into an arraylist I want to pass it to Object's array. I though using toArray() function will help. If you have any example of how to use toArray function without getting any error,it would be great help.