Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在java(android Studio)中填充数组的一个单元格_Java_Android_Arrays_For Loop_Debugging - Fatal编程技术网

如何在java(android Studio)中填充数组的一个单元格

如何在java(android Studio)中填充数组的一个单元格,java,android,arrays,for-loop,debugging,Java,Android,Arrays,For Loop,Debugging,我写了这个,但是所有的单元格都填满了。 我怎样才能修好它 Integer [] history=new Integer[5]; for (int i=0;i<history.length;i++) { history[i]=Jamkon.intValue(); } txt_H.setText(Arrays.toString(history)); Integer[]历史记录=新整数[5]; 对于(int i=0;i您使用的是一个循环,它将遍历数组的所有索引。如果您只想

我写了这个,但是所有的单元格都填满了。

我怎样才能修好它

 Integer [] history=new Integer[5];

 for (int i=0;i<history.length;i++) {
     history[i]=Jamkon.intValue();
 }

 txt_H.setText(Arrays.toString(history));
Integer[]历史记录=新整数[5];

对于(int i=0;i您使用的是一个循环,它将遍历数组的所有索引。如果您只想写入一个值,您必须先决定索引是什么

    int index =??? 
    history[index] = Jamkon.intValue()

您正在使用一个循环,该循环将遍历数组的所有索引。如果您只想写入一个值,则必须首先确定
索引的内容

    int index =??? 
    history[index] = Jamkon.intValue()

在您编写
txt_H.setText(Arrays.toString(history))之后;
输出是什么,您希望得到什么作为正确的输出?请检查:在您编写
txt_H.setText(Arrays.toString(history))之后
输出是什么?您希望得到什么作为正确的输出?检查:我希望下次单击按钮时打印第一个单元格打印最后一个单元格和下一个单元格,直到所有单元格都填满。您需要将该索引保存在某个位置,并在用户每次单击时读取/写入。请显示更多代码。我修复了它tnx先生。请检查我的索引回答为解决问题,或者更确切地说,将您自己的解决方案作为正确答案发布给其他人以供将来查看!我希望下次单击按钮时打印第一个单元格打印最后一个单元格和下一个单元格,直到所有单元格都填满为止。您需要将该索引保存在某个位置,并在用户每次单击时读取/写入。请显示更多代码。我修复了它先生,请在解决问题时检查我的答案,或者更确切地说,将您自己的答案作为正确答案发布给其他人,以供将来查看!