java.util.Optional ã使ãããæ°æã¡ã¯ããããã©ããªãã§ãããã§ã Optional ã§æ¸ãã°è¯ãã¨ãããã®ã§ã¯ãªãã
(æ©æ¢°ç¿»è¨³ã£ã½ãè¨äºããåºã¦ããªãã)
javaer101.com
åæåããã¦ããªããã°åæåããå¦çã Optional ã使ã£ã¦æ¸ãã¨ä»¥ä¸ã®ããã«ãªãã
List list = Optional.ofNullable(list).orElse(new ArrayList<>());
ãã®å ´å 2 åç®ä»¥éã®å¼ã³åºãã§ã¯ãå é¨ã§ Optional ã¤ã³ã¹ã¿ã³ã¹ãã¤ãããã¦ã¯ãåç §ãããªãããã«ããã«ç ´æ£ãããã¨ããã³ã¼ãã«ãªãã
ç´ ç´ã«ä¸é æ¼ç®åã if æã§æ¸ããæ¹ãè¯ãã¨æãã