0

I have a function from a library whose signature says:-

public void setColumnNames(N... columnNames);

1.) What is the meaning of 'N...' ?

Also I have a list like this:- List<HColumn<String,String>>

I want to extract the 1st String of each element HColumn of this list and pass all these Strings as a single argument in above function. I am doing this job to compute the things that need to be displayed on a page of a website. Thus I need a superfast method to do so.

2.) How do I go for it ??

3
  • 1) Varargs download.oracle.com/javase/1.5.0/docs/guide/language/… Commented Feb 20, 2011 at 5:55
  • 2) Build an array of type N[] with the same length as the list, transfer the strings from the list to the array (converting them from String to N, however that's done), and pass the array as the argument to the function. Commented Feb 20, 2011 at 5:56
  • 1
    @Vance you should consider putting those in an answer!
    – corsiKa
    Commented Feb 20, 2011 at 6:01

2 Answers 2

2
public void setColumnNames(N... columnNames)

means that setColumnNames takes any number of arguments of type N.

This feature is called varargs.

1

Taking glowcoder's suggestion, here's the other part:

2) Build an array of type N[] with the same length as the list, transfer the strings from the list to the array (converting them from String to N, however that's done), and pass the array as the argument to the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.