小编Cfe*_*rel的帖子

你如何正确地在java中附加两个2D数组?

我一直在尝试在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)

java arrays append

1
推荐指数
1
解决办法
1万
查看次数

这在数组中如何工作?

你好我写这段代码有困难,我在最后两种方法中迷失了.这是一个学习练习(不是家庭作业),但我需要学习的例子.另外我认为这在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)

java arrays methods

0
推荐指数
1
解决办法
238
查看次数

标签 统计

arrays ×2

java ×2

append ×1

methods ×1