Posts Tagged ‘null’
Null returned from a method returning a collection or an array
Null should never be returned from a method returning a collection or an array. Instead return a empty array (a static final empty array) or one of the empty collections (e.g. Collections.EMPTY_LIST
assuming the client should not be modifying the collection).
(submitted by Rand McNeely)
‘equals()’ does not check for null argument
If you override equals()
method in your class, always check if an argument is null. If a null value is passed, equals()
must unconditionally return false
(no NullPointerException
should be thrown!).