【问题标题】:Double ArrayList multiplication双 ArrayList 乘法
【发布时间】:2016-06-20 14:03:55
【问题描述】:

我有三个 Double Arraylist。我想将数组 1 到数组 2 并将其放在第三个数组中。

// ArrayList 1 
[0.0, 1.0, 0.0, 1.0]

// ArrayList 2 
// Random number generated by random()
[0.37668669271524147, 0.429455596516655, 0.7337191115424969, 0.29389239043901294, 0.7050413406305202] 

还有我的代码

for (int i = 0; i < plans.size(); i++) {

    for (int j = 0; i < value.size(); j++) {
        try { 
            plansval.add(plans.get(i) * value.get(j)); 
        }
        catch (IndexOutOfBoundsException e) {
            System.out.println("IndexOutOfBoundsException: " + e.getMessage()); 
        }
    }
}

我收到IndexOutofBoundsExceptions。 你能帮我解决这个问题吗谢谢。

【问题讨论】:

    标签: java arraylist indexoutofboundsexception


    【解决方案1】:

    您的代码中有错字。换个方式

     for (int j = 0; i < value.size(); j++) {
    

     for (int j = 0; j < value.size(); j++) {
    

    【讨论】:

    • 谢谢。这么简单的东西我都没看到。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多