Why is System.arraycopy native in Java?

后端 未结 5 1603
囚心锁ツ
囚心锁ツ 2020-11-28 03:07

I was surprised to see in the Java source that System.arraycopy is a native method.

Of course the reason is because it\'s faster. But what native tricks is the code

5条回答
  •  余生分开走
    2020-11-28 03:55

    In native code, it can be done with a single memcpy / memmove, as opposed to n distinct copy operations. The difference in performance is substantial.

提交回复
热议问题