Question on Effective Java Item 27
- From: "hforco@xxxxxxxxxxxxxx" <hforco@xxxxxxxxxxxxxx>
- Date: 20 Apr 2006 07:25:33 -0700
In Joshua Bloch's Effective Java, Item 27 ("Return zero-length arrays,
not nulls"), he concludes with the following words:
"In summary, there is no reason ever to return null from an
array-valued method instead of returning a zero-length array."
I'm not convinced this is correct.
For example, let's say I have a look-up method for some data:
byte[] findData(Object key);
Surely in this case a zero-length returned value could be meaningful in
itself, and so in this case we should return either null, or throw an
exception, if an invalid key was used.
Any thoughts?
.
- Follow-Ups:
- Re: Question on Effective Java Item 27
- From: Andrew McDonagh
- Re: Question on Effective Java Item 27
- From: S Perryman
- Re: Question on Effective Java Item 27
- Prev by Date: UML inner/nested class associations
- Next by Date: Re: Question on LSP
- Previous by thread: UML inner/nested class associations
- Next by thread: Re: Question on Effective Java Item 27
- Index(es):