我一直在尝试在java中附加两个2 D数组.是否有可能得到一个例子,因为我一直试图查找它但找不到一个.
int [][]appendArray(empty,window)
{
int [][]result= new int [empty.length][empty[0].length+window[0].length];
}
Run Code Online (Sandbox Code Playgroud) 你好我写这段代码有困难,我在最后两种方法中迷失了.这是一个学习练习(不是家庭作业),但我需要学习的例子.另外我认为这在stackoverflow数据库中也很有用.
public class NumberList {
public int[] values;
public NumberList() {
values = new int[0];
}
public NumberList(int[] a) {
values = new int [a.length];
for (int i=0;i<a.length;i++)
values[i] = a[i];
}
public int getSize() {
return this.values.length;
}
public int getAt(int index) {
if (index>=values.length){
throw new IndexOutOfBoundsException ("Values of out of bounds");
}else{
return values[index];
}
}
public long getTotal() {
long sum = 0;
for (int i=0; i<values.length; i++) {
sum = sum + values[i];
}
return …
Run Code Online (Sandbox Code Playgroud)