开发者

java one element list

开发者 https://www.devze.com 2023-02-16 12:26 出处:网络
What is the most efficient (performant) way to create a list with just one el开发者_Go百科ement? Just use:

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

精彩评论

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