Only the last parameter is allowed for the Length variable:
String prepareStatement(String[] columnNames, String... values)
String ... is equal to String [], so in this case you can insert String [] for the first parameter and just check if it is empty or how long it will be.
Edit Your Editing
If you really need an input for all your lines as parameters, I would recommend defining a really very unusual line to separate your inputs:
static String prepareStatement(String... params) { String ret = ""; boolean valueInput = false; for(String s : params) { if(s.equals("MyReallyUncommonSeperateString")) { valueInput = true; ret+="\nvalues\n";//visual delimiter of columnNames and Values } else if(valueInput) { //handling of your value inputs ret+=s; //example handling, concatenate everything } else { //handling of your columnnames ret+=s; //example handling, concatenate everything } } return ret; }
You can call it:
System.out.println(prepareStatement("a","b","c","d","e","MyReallyUncommonSeperateString","f","g","h","i","j","k"));
Output:
abcde values fghijk
Another way is to also specify the length of the column name as a parameter:
static String prepareStatement(int length, String... params) { String ret = ""; for(int i = 0; i < length; i++){ //handling of columnnames String colName = params[i]; //do something with colName ret+=colName; //example handling, concatenate everything } ret+="\nvalues\n";//visual delimiter of columnNames ans Values for(int i = length; i < params.length; i++){ String value = params[i]; //do something with values ret+=value; //example handling, concatenate everything } return ret; }
With a call:
System.out.println(prepareStatement(5, "a","b","c","d","e","f","g","h","i","j","k"));
And the same conclusion:
abcde values fghijk