2on*_*one 4 java arrays instance-variables
我是 Java 新手。我有一个可以为其创建实例的类。在类中,我定义了两个实例变量:
double[] array1;
double[] array2;
数组的长度相等。
Within the class I then have a method1 that first populates array1 and then another method2 in which I want to set some of the array2 values = the values in array1 (based on array element index) but also then modify (perform additional operation on) some of the values in array2 (based on array element index). I have tried to do this within method2 by first setting:
array2 = array1;
and then modifying some of the array2 values based on element index but I see that array1 has been completely modified to equal array2 so realise there is something fundamentally wrong with my approach in Java.
| 归档时间: |
|
| 查看次数: |
75 次 |
| 最近记录: |