1

Possible Duplicate:
Java, 3 dots in parameters

In jedis the are using the construct String... keys(this is something new??)

For example this method

jedis.blpop(int timeout, String... keys);

I believe you can use this as both a String as an array. How can I use this in my code(example)?

Community
  • 1
  • 1
Alfred
  • 60,935
  • 33
  • 147
  • 186

2 Answers2

5

Those are Java's variadic arguments

You could pass an array of strings or a bunch of String objects.

Passing a String[] array.

String sarr[] = {"key1", "key2", "key3"};
jedis.blpop(someTimeout, sarr);

Passing several String objects separately:

jedis.blpop(someTimeout, "key1", "key2", "key3")

wkl
  • 77,184
  • 16
  • 165
  • 176
0

See varargs in the Java Tutorial.

Steve Emmerson
  • 7,702
  • 5
  • 33
  • 59