File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Collections - toArray Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Collections - toArray Method" Watch "Collections - toArray Method" New topic
Author

Collections - toArray Method

Landon Blake
Ranch Hand

Joined: Dec 04, 2003
Posts: 121
The Collection Documentation States:
"The toArray methods are provided as a bridge between collections and older APIs that expect arrays on input. They allow the contents of a Collection to be translated into an array. The simple form with no arguments creates a new array of Object. The more complex form allows the caller to provide an array or to choose the runtime type of the output array."
When toArray is called, and the collection is "translated" to the array, do the objects still exist in the LinkedList.
Can I call toArray on the same LinkedList multiple times to create arrays with different names but containg the same set of objects?
Thanks,
Landon
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Calling toArray() doesn't change a collection in any way, so the answer to both your questions is "yes".


[Jess in Action][AskingGoodQuestions]
Landon Blake
Ranch Hand

Joined: Dec 04, 2003
Posts: 121
Thanks Ernest...That's what I suspected.
Landon
[ May 06, 2004: Message edited by: Landon Blake ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Collections - toArray Method