This week's book giveaways are in the Cloud and AI/ML forums. We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line! See this thread and this one for details.
The following snippet dumps the contents of c into a newly allocated array of String whose length is identical to the number of elements in c: String a = (String) c.toArray(new String);
Why does it give the array argument a length of 0? And not the amount of elements in c? Best regards, Gian Franco Casula [ February 20, 2004: Message edited by: Gian Franco Casula ] [ February 20, 2004: Message edited by: Gian Franco Casula ] [ February 20, 2004: Message edited by: Gian Franco Casula ]
In the case of the empty array, toArray will use the type to create a new array. However, if you know the size, you can pass in an array of exactly the right size and it will be used. I suppose they figure it is more flexible to provide both ways of operating. Bill