Utility method for wrapping an object in a collection

前端 未结 5 739
抹茶落季
抹茶落季 2021-02-06 22:44

I\'m looking for a static method in the Java core libraries or some other commonly used dependency — preferably one of Apache — that does the following:

public s         


        
5条回答
  •  自闭症患者
    2021-02-06 22:47

    java.util.Collections.singletonList() or singleton(). Note though that the result is immutable.

提交回复
热议问题