Utility method for wrapping an object in a collection

前端 未结 5 683
抹茶落季
抹茶落季 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 23:07

    Don't be afraid of writing something yourself. As far as I know it doesn't exist. I think a reason for this is that the utility method decides which implementation of Collection it uses. In your case you chose for ArrayList, but there are a whole bunch of other collections.

提交回复
热议问题