# How to check if an Array was defined?

**URL:** <https://discourse.processing.org/t/how-to-check-if-an-array-was-defined/9297>\
**Category:** Beginners\
**Created:** [March 14, 2019, 4:17pm UTC](https://discourse.processing.org/t/how-to-check-if-an-array-was-defined/9297 "2019-03-14T16:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)\
**Post date:** [March 14, 2019, 4:17pm UTC](https://discourse.processing.org/t/how-to-check-if-an-array-was-defined/9297/1 "2019-03-14T16:17:18Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [March 14, 2019, 4:45pm UTC](https://discourse.processing.org/t/how-to-check-if-an-array-was-defined/9297/2 "2019-03-14T16:45:36Z")

</div>

There are two possibilities, either the method returns `null` or an empty array, you can check for both with

```auto
  if(allData != null && allData.length > 0){ 
    // We got some stuff in the array
  }

```

---

<div class="post-metadata">

**Author:** ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)\
**Post date:** [March 14, 2019, 4:48pm UTC](https://discourse.processing.org/t/how-to-check-if-an-array-was-defined/9297/3 "2019-03-14T16:48:24Z")

</div>

Thanks! Forgot to test for null…
