无限重复循环

时间:2019-04-20 18:33:55

标签: android for-loop arraylist nested-loops

我正在使用嵌套的for循环从arraylist获取数据,并且该循环无限运行

私有ArrayList prepareData()     {

    ArrayList arrayList = new ArrayList<>();
    for(int i=0;i<android_image_urls.length;i++){

            Androidversionclass androidversion = new Androidversionclass();
            androidversion.setAndroid_image_url(android_image_urls[i]);
            arrayList.add(androidversion);

                for (int k= 0; k < android_image_second.length; k++) {
                    Androidversionclass androidversionclass1 = new Androidversionclass();
                    androidversion.setAndroid_image_second(android_image_second[k]);
                    arrayList.add(androidversion);
                }

                for (int l = 0; l < android_image_thirds.length; l++) {
                    Androidversionclass androidversionclass2 = new Androidversionclass();
                    androidversion.setAndroid_image_thirds(android_image_thirds[l]);
                    arrayList.add(androidversion);

                }

                for (int m = 0; m < android_image_fourth.length; m++) {
                    Androidversionclass androidversionclass3 = new Androidversionclass();
                    androidversion.setAndroid_image_fourth(android_image_fourth[m]);
                    arrayList.add(androidversion);
            }
        }
    return arrayList;
}

0 个答案:

没有答案