Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

toArray() question

 
Charith Fernando
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have seen code segments which uses the toArray() in different ways... just want to know the best mechanism and the difference...

(1)



(2)




please note that this is in Java 1.4 in Java 5 we dont need the cast if we have a list which will only contain Strings...


Thank you
Charith
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If the passed array is large enough to contain the values to be returned, the method returns the passed array reference (that now contains the values to be returned) and not a newly created one.
[ October 23, 2006: Message edited by: wise owen ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic