"I disagree with what you are saying, but I will defend to the death your right to say it." -- not clear who
Zie de API docs van Collection. Hier staat het goed uitgelegd. Je moet de methode met de parameter hebben:
Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.
If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of this collection only if the caller knows that this collection does not contain any null elements.)
If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the toArray method, this method acts as bridge between array-based and collection-based APIs. Further, this method allows precise control over the runtime type of the output array, and may, under certain circumstances, be used to save allocation costs
Suppose l is a List known to contain only strings. The following code can be used to dump the list into a newly allocated array of String:
code:
1 String[] x = (String[]) v.toArray(new String[0]);
Note that toArray(new Object[0]) is identical in function to toArray().
Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment
Overigens kan je natuurlijk nog beter hier een kijkje nemen
: http://java.sun.com/developer/earlyAccess/adding_generics/
Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment
waarom weet jij alles?Op vrijdag 30 november 2001 21:05 schreef mbravenboer het volgende:
42
beetje irritant hoor
"I disagree with what you are saying, but I will defend to the death your right to say it." -- not clear who
Geloof het of niet, zelfs mbravenboer weet echt niet allesGiLuX: waarom weet jij alles?
Dat wel jahbeetje irritant hoor
Graag gedaanGiLuX: waarom weet jij alles?
beetje irritant hoor
Tsss, gedraag je een beetjetomato Geloof het of niet, zelfs mbravenboer weet echt niet alles
Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment
Pagina: 1