code: public static String splitListByComma(List<String> hosts) {
          boolean firstHost = true;
          StringBuilder hostConnection = new StringBuilder();
          for (String host : hosts) {
              if (!firstHost) {
                  hostConnection.append(",");
              }
              hostConnection.append(host.trim());
              firstHost = false;
          }
          return hostConnection.toString();
      }
docs: Split list by comma.
  
  @param hosts the hosts
  @return string