java parameter "..." the usage and meaning

  1. public static void executebindParam(PreparedStatement pstmt,Object ...os){
  2. int len = os.length;
  3. try {
  4. for (int i = 0; i  len; i++) {
  5. pstmt.setObject(i+1, os[i]);
  6. }
  7. catch (SQLException e) {
  8. e.printStackTrace ();
  9. }
  10. }

 

Object ... os The wording is from the beginning of Java 5, Java language method parameters to support a new wording, called variable-length argument list.

Represents a parameter as an object here to accept a plurality of type Object to 0, or an Object []

Note that the format of the variable length argument list:

    1. Parameter types and "..." do not have to have a space (Object ... os) between the three points, Object ... os does not report an error;
    2. Variable-length argument lists this parameter must be the last argument in the argument list, or will be error

Guess you like

Origin www.cnblogs.com/a1304908180/p/11542353.html