Get the App
SLTechnology News&Howtos  ›  Development  › 

Do not return null in java development

Shulou Source: shulou.com Published: 2022-06-01 06:16:38 10月03日 Update

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!

Tags: Development content more articles good practical subcategories subdirectories pointers articles methods look knowledge reference help related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno macOS Xiaomi MySQL Linux