code: protected String genIdString (int[] userIds)
      {
          // build up the string we need for the query
          StringBuilder ids = new StringBuilder();
          for (int i = 0; i < userIds.length; i++) {
              if (ids.length() > 0) {
                  ids.append(",");
              }
              ids.append(userIds[i]);
          }
  
          return ids.toString();
      }
docs: Take the passed in int array and create the a string suitable for using in a SQL set query
  (I.e., "select foo, from bar where userId in (genIdString(userIds))"; )