• Post Reply Bookmark Topic Watch Topic
  • New Topic

array copy

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is System.arrayCopy faster than an for loop. Is it because the arrayCopy method is native?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes -- although it's not necessarily always faster. For small arrays, the overhead associated with the native call and with the various type coercions and other checks that are done can make it a bit slower than the equivalent for loop.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!