java one element list
What is the most efficient (performant) way to create a list with just one el开发者_Go百科ement?
Just use:
Collections#singletonList()
, which returns aList
, orCollections#singleton()
, which returns aSet
.
Consider Collections.singletonList() for a list of 1 element.
精彩评论