2013-05-14 9 views
0

나는이 코드를 연구 중이며 여러 매개 변수가있는 생성자입니다. 마지막 파라미터의 선언은 ... 무엇을 의미합니까?자바 - 매개 변수 선언

그것은 가변 인자라고
/** 
* Public constructor. 
* @param servicePort the service port 
* @param nodeAddresses the node addresses 
* @param sessionAware true if the server is aware of sessions, false otherwise 
* @throws NullPointerException if the given socket-addresses array is null 
* @throws IllegalArgumentException if the given service port is outside range [0, 0xFFFF], 
* or the given socket-addresses array is empty 
* @throws IOException if the given port is already in use, or cannot be bound 
*/ 
public TcpSwitch(final int servicePort, final boolean sessionAware, final InetSocketAddress... nodeAddresses) throws IOException { 
    super(); 
    if (nodeAddresses.length == 0) throw new IllegalArgumentException(); 

    this.serviceSocket = new ServerSocket(servicePort); 
    this.executorService = Executors.newCachedThreadPool(); 
    this.nodeAddresses = nodeAddresses; 
    this.sessionAware = sessionAware; 

    // start acceptor thread 
    final Thread thread = new Thread(this, "tcp-acceptor"); 
    thread.setDaemon(true); 
    thread.start(); 
} 
+3

그것은 [가변 인자 매개 변수 (http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html) – Vladimir

답변

6

, 최종 인수가 배열 또는 인수의 순서로 전달 될 수 있음을 나타냅니다 마지막 매개 변수의 유형 후 더 http://docs.oracle.com/javase/1.5.0/docs/guide/language/varargs.html

세 기간 동안 이쪽을 봐주세요. Varargs는 최종 인수 위치에서만 사용할 수 있습니다.

코드에서 알 수 있듯이이 코드는 배열입니다.

+0

들으, 나는에 동의 윌의 10 분 – user1477955