Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 我需要帮助创建实例变量和构造函数
第二个构造函数将接受一个参数,它将是一个 int 数组。此构造函数将创建一个与参数大小相同的实例数组,然后将整数从参数复制到实例数组。
this.myArray = Arrays.copyOf(nrray,nrray.length);
这应该创建传入 int 数组的副本并将其分配给实例数组