Using multiple map functions vs. a block statement in a map in a java stream

北慕城南 提交于 2019-11-29 05:55:34

Either is fine. Pick the one that seems more readable to you. If the calculation naturally decomposes, as this one does, then the multiple maps is probably more readable. Some calculations won't naturally decompose, in which case you're stuck at the former. In neither case should you be worrying that one is significantly more performant than the other; that's largely a non-consideration.

java has provided a dedicated API to handle with "null".

https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!