Home > Java > JavaBase > What does the parameter '...' mean in java

What does the parameter '...' mean in java

王林
Release: 2020-02-01 20:45:01
Original
4760 people have browsed it

What does the parameter '...' mean in java

First let’s take a look at the method of binding parameters encapsulated in jdbc, as follows:

/**
* 绑定参数
* @param pstmt
* @param os
*/
 
public static void executebindParam(PreparedStatement pstmt,Object ...os){
 
    int len = os.length;
 
    try {
 
        for (int i = 0; i < len; i++) {
 
            pstmt.setObject(i+1, os[i]);
 
        }
 
    } catch (SQLException e) {
 
        e.printStackTrace();
 
    }
 
}
Copy after login

Recommended learning: java video tutorial

The analysis is as follows:

Object ...osThis writing method started from Java 5. The Java language supports a new writing method for method parameters, called variable Length parameter list. Indicates that the parameters accepted here are 0 to multiple Object type objects, or an Object[].

Note the format of the variable-length parameter list:

1. There must not be a space between the parameter type and the three dots "..." (Object ...os), Object ...OS will not report an error;

2. Variable length parameter list This parameter must be the last parameter in the parameter list, otherwise an error will be reported.

Recommended related articles and tutorials: java introductory tutorial

The above is the detailed content of What does the parameter '...' mean in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template