[英]ArrayOutOfBoundsException error
I'm writing a program with java that analyses stock data. 我正在用Java编写一个用于分析股票数据的程序。
I almost got it working but now it gives me an ArrayOutOfBounds Exception. 我几乎可以正常工作,但是现在它给了我ArrayOutOfBounds异常。
int n = closingPrices.size();
double[][] cParray = new double[n][1];
for(int i = 0; i < n; i++)
{
cParray[i][1] = closingPrices.get(i);
}
I hope you can give me help on how to solve this problem.. 希望您能帮我解决这个问题。
the size of cParray[i] is 1. It can have only one element with the index [0] cParray [i]的大小为1。它只能有一个索引为[0]的元素
so try cParray[i][0] = closingPrices.get(i)
因此请尝试
cParray[i][0] = closingPrices.get(i)
OR double[][] cParray = new double[n][2]
或
double[][] cParray = new double[n][2]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.