Do not return null in java development
This article is about not returning null in java development. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Do not return null
Counterexample
Positive example
Avoid unnecessary null pointers when calling methods elsewhere
Optional null judgment
/ / get the subdirectory list public List getChild (String pid) {if (V.isEmpty (pid)) {pid = BasicDic.TEMPORARY_DIRECTORY_ROOT;} CatalogueTreeNode node = treeNodeMap.get (pid); return Optional.ofNullable (node) .map (CatalogueTreeNode::getChild) .orElse (Collections.emptyList ());} Thank you for reading! This is the end of this article on "do not return null in java development". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!