欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Return zero length collections or arrays as opposed to returning null

程序员文章站 2022-07-15 10:10:50
...

Returning null instead of zero
length collection (use Collections.EMPTY_SET, Collections.EMPTY_LIST, Collections.EMPTY_MAP) is more
error prone, since the programmer writing the calling method might forget to handle a return value of null.