打印数组的索引

时间:2015-12-01 18:48:54

标签: java printing

我无法弄清楚为什么我的j无法使用当前的boolean声明打印出来。只有当我放!=它才会打印100,000-1索引。

public static void main(String[] args) {
    //array size and name
    double[] largearr; 
    largearr = new double[100000];
    double index = 0.00149;
    int j = 0;

    //population of array and the printout of the elements
    for(int i = 0; i < 100000; i++) {
        Arrays.fill(largearr, index);
        index += 0.00149;
        // System.out.println(largearr[i] + " ");
    }

    for(j = 0; j < largearr.length; j++) {
        if(largearr[j] == 58.00122999995376) {
            System.out.println("j");
        }
    }
}  

1 个答案:

答案 0 :(得分:0)

因为您在大公司的任何位置都没有这个价值。代码中的第一个for循环使用新增加的索引值填充largearr数组的所有元素,并且它会执行100000次:最后,您将填充上一次迭代的索引值,那肯定不是58.00122999995376。所以第二个for循环没有输入if检查任何值,程序退出而不打印任何东西。

如果你能解释一下你想要实现什么,也许我们可以帮助你。

相关问题