开发者

Null Pointer Exception for Array List during Run Time but not in the debug mode

开发者 https://www.devze.com 2023-03-30 08:23 出处:网络
I have an array list in my class and am getting the value for it as, ArrayList<VenueIcons>venueArrays = TourDescription.currentTour.getVenues();

I have an array list in my class and am getting the value for it as,

ArrayList<VenueIcons>  venueArrays = TourDescription.currentTour.getVenues();

I am usin开发者_如何学Gog this array in my for loop

for (VenueIcons objVenues : venueArrays)     {



}

The problem is, this works fine when I am in the debug mode, but when I try to run it it throws null pointer exception for the same array.

When I debug it, I get all the values for venueArrays without any problem.

Trying to find what went wrong


You should give some delay time for getting response for your http call.It should work.


This usually happens when you are dealing with a time based operation. Most probably getVenues() method needs some time in order to fill up the array. So when you are in debug mode it has enough time to do that. In other case it just returns null. You may try to insert a 'sleep' before calling getVenues(). Then observe what is actually happening in getVenues() method.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消