Passing List<String> to String… parameter
问题 I'm struggling to pass a List of Strings into a method requiring the parameter " String... ". Can anybody help me out? // How to put names into dummyMethod? List<String> names = getNames(); public void dummyMethod(String... parameter) { mInnerList.addAll(Arrays.asList(parameter)); } 回答1: You'll have to convert the List<String> to a String array in order to use it in the 'varargs' parameter of dummyMethod . You can use toArray with an extra array as parameter. Otherwise, the method returns an