June 2018
Beginner
722 pages
18h 47m
English
The following methods of the class Objects check the value of the first parameter and, if the value is null, either throw NullPointerException or return the provided default value:
String object = null; try { Objects.requireNonNull(object); } catch (NullPointerException ex){ System.out.println(ex.getMessage()); //prints: null }
String object = null; try { Objects.requireNonNull(object, "Parameter 'object' is null"); } catch (NullPointerException ex){ System.out.println(ex.getMessage()); //Parameter ...
Read now
Unlock full access