[英]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.