且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Java IndexOutOfBound 异常在Android 中使用arraylist

更新时间:2023-11-19 20:45:40

关于这部分:

for(int i =0;i<allPPLlat.size();i++){
           double Dist= Distance((double)allPPLlat.get(i),(double)allPPLlong.get(i),latitude,longitude);
            Dist=Dist/1000;
            if(Dist<20){
                Donors.add(new DonorPerson(""+allPPLNames.get(i)+"", ""+allPPLEmails.get(i)+"" ,""+allPPLNumbers.get(i)+"" ,""+allPPLImages.get(i)+""));
            }
        }

您正在为空数组的位置 0 执行 get 操作,该数组不存在并抛出您看到的错误.堆栈跟踪实际上将您指向确切的位置.

You are doing a get for the position 0 of an empty array, which does not exist and throws the error you are seeing. The stack trace is actually pointing you to the exact location.