开发者

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 a List, or
  • Collections#singleton(), which returns a Set.


Consider Collections.singletonList() for a list of 1 element.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜