code: public static String trimComma(String s) {
          if (s.endsWith(",")) {
              s = s.substring(0, s.length() - 1);
          }
          return s;
      }
docs: Trim trailing comma from given string.
  
  @param s
  a string
  @return the same string with trailing comma trimmed (if any)