Jeet.Deir Jeet.Deir - 6 months ago 62
Java Question

Singleton Collection To Multiple Object Collection

So I was initially using a singleton list to pass data to Google Cloud API like this:


How can I change the
to send multiple objects like this:

inputInput.setCsvInstance(Collections.<Object>singletonList("5.656346", "2.43485744", ...));

EDIT: I don't want to keep a singleton. I need to change it to multiple one, singleton doesn't allow me that. What keyword should I use instead of singleton is my question.



A singleton list has only 1 element by definition. If you want a list with multiple elements, you can use Arrays.asList():

inputInput.setCsvInstance(Arrays.asList("5.656346", "2.43485744", ...));