Returning null instead of zerolength collection (use Collections.EMPTY_SET, Collections.EMPTY_LIST, Collections.EMPTY_MAP) is moreerror prone, since the programmer writing the calling method might forget to handle a return value of null.
Return zero length collections or arrays as opposed to returning null
最新推荐文章于 2021-10-26 17:34:08 发布
本文讨论了在编程中使用空集合而非返回null的重要性,强调了返回null可能导致的错误处理问题。推荐使用Collections.EMPTY_SET, EMPTY_LIST 或 EMPTY_MAP来代替返回null,以减少潜在的NullPointerException风险。
5万+

被折叠的 条评论
为什么被折叠?



