Java中数组的clone方法为什么是浅复制

来源:互联网 发布:les小说软件 编辑:程序博客网 时间:2024/05/18 00:28

native方法中最核心的代码,C++中的指针,*a = *b, 复制地址,所以就是浅复制了。

static void pd_conjoint_oops_atomic(oop* from, oop* to, size_t count) {    // Do better than this: inline memmove body  NEEDS CLEANUP      if (from > to) {      while (count-- > 0) {        // Copy forwards        *to++ = *from++;      }    } else {      from += count - 1;          to   += count - 1;      while (count-- > 0) {        // Copy backwards        *to-- = *from--;      }    }  }