I have the following simple code piece:
List<XXXXBean> queryPeriodData()
{
if (CollectionUtils.isEmpty(res))
{
return Collections.emptyList();
}
return res;
}
It works.
but if I change to this, there is a compile error...
return CollectionUtils.isEmpty(res) ? Collections.emptyList() : res;
error message is
I don't know the difference between the two way.
在语句中尝试Collections.<XXXXBean>emptyList()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.