3 ms·
Because then you cannot differentiate anymore between "NullPointerException as a bug" or "NullPointerException as a feature". E.g. you might want to return the
by valenterry 5y ago
Because then you cannot differentiate anymore between "NullPointerException as a bug" or "NullPointerException as a feature".
E.g. you might want to return the streetnumber of a user's address. When a NPE is thrown, was it because there is a bug somewhere in the code or because the user's address has no street number?
With Optional, it is clear: there was no street number.