0

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

inputInput.setCsvInstance(Collections.<Object>singletonList("Ear"));

How can I change the singletonList 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.

Thanks.

Jishan
  • 1,654
  • 4
  • 28
  • 62
  • 2
    You might want to look up the meaning of "singleton". – shmosel Sep 28 '16 at 21:09
  • So you want a _singleton_ list to contain multiple elements? A singleton list can only contain one element. What are you actually trying to do? – Tunaki Sep 28 '16 at 21:09
  • 1
    I don't want to keep a singleton. I need to change it to multiple one, singleton doesn't allow me that. – Jishan Sep 28 '16 at 21:10

1 Answers1

8

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", ...));
shmosel
  • 49,289
  • 6
  • 73
  • 138