[英]Why this method returns "null" but not null
我有这个方法可以从remittanceInformation
对象中提取一些信息
private static String combineStrings(RemittanceInformation remittanceInformation) {
return Optional.ofNullable(remittanceInformation)
.map(RemittanceInformation::getUstrds)
.map(l -> l.stream().collect(Collectors.joining(/* CRLF? */)))
.orElse(null);
}
现在remittanceInformation
所有内容都是null
并且在这种情况下的方法应该返回null
但它返回带双引号的"null"
,为什么会出现这种行为?
字符串的连接提供一个字符串,如果有一个项为空,则可能是“空”(“”+空)。 情况一定是这样:一个非空的 remittanceInformation,其中 getUstrds() 给出一个带有单个空值的集合。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.