Gotcha, the dataset is best checked simply before you intend to read from it. If you have already initialized it to the proper size, than there is no chance a *write* can fail (assuming datatype is correct of course, unless something is *really* broken, like beyond code issue broken
), so the problem is a read.
The easiest thing to do is simply use a try/catch for a NullPointerException. Alternatively, ensure you capture an object from an array and check its null status before you operate on it. IE:
String astr = new String;
String str = astr;
if (str != null)
For example. Try catch is pretty much the same:
catch (NullPointerException ex)
They both have about the same logic.