Hi!
So I have this String Array in my little programm called allData
and it is defined by allData = saveStrings(URL);
. But what if there’s no wifi connection on the device? The programm will crash instantly, because I use split to scatter the contents of allData
into an other Array. I want to avoid that by checking if the array is undefinend. But how? Or is there another possibility?
1 Like
There are two possibilities, either the method returns null
or an empty array, you can check for both with
if(allData != null && allData.length > 0){
// We got some stuff in the array
}
3 Likes
Thanks! Forgot to test for null…