The following code
public final double[] array = {1, 1}; //cannot be null because 'array' is final
private double[] getArray() {
if (null != array && someCondition) { //redundant check for null
return array;
}
array[0] = 42; //compiler warning
return array;
}
produces compiler warning:
Array access 'array[0]' will produce 'NullPointerException'
This warning goes away if the redundant check for null is removed.
Can there really be a NullPointerException
during execution the above code?