简体   繁体   中英

Meaning of int… or N… in java

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 ??

public void setColumnNames(N... columnNames)

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

This feature is called varargs .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM