---
title: "Return zero length collections or arrays as opposed to returning null"
author: "bd2007"
date: "2011-08-02T17:37:48Z"
tags: []
categories: ["Web前端"]
slug: "return-zero-length-collections-or-arrays-as-opposed-to-returning-null"
draft: false
lastmod: "2011-08-02T17:37:48Z"
id: 1138433
url: "https://bd2007.iteye.com/blog/1138433"
---

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.