How to convert a List to variable argument parameter java

java_geek picture java_geek · May 25, 2013 · Viewed 60.1k times · Source

I have a method which takes a variable length string (String...) as parameter. I have a List<String> with me. How can I pass this to the method as argument?

Answer

FloF picture FloF · May 25, 2013

String... equals a String[] So just convert your list to a String[] and you should be fine.