NullPointerExceptions are programming errors by nature.
What could you do if the given array is null? A. skip the check. A better alternative would be to return an empty array:
public Object [] getMyObjects() {
/// do a lot of stuff
if( nothingToReturn() ){
return new Object[0];
} else {
return nonNullArray;
}
}
So
if( x.length > 0 )
Never throws Npe in first place.
Although It would be nice, very soon you'll realize your code will be unreadable.
That's why "encapsulation" is such an important concept in OOP ( that way other object's won't nullify your data ) .
I think it's fair to check if external classes return null or not ( which by the way should be well documented ) but for internal methods, the real problem is, the own object doesn't know the state of its own instance variables.
NOTE This was too large for a comment, that's why I provided a CW answer instead.