public static String trimComma(String s){
  if (s.endsWith(",")) {
    s=s.substring(0,s.length() - 1);
  }
  return s;
}

public static String trimComma ( String s ) { if ( s . endsWith ( "," ) ) { s = s . substring ( 0 , s . length ( ) - 1 ) ; } return s ; }
trim trailing comma from given string .
