Remove last comma from string

/** * This method removes last comma of input string. * * @param strInput * @return */ public static String removeLastComma(String strInput) { String newstr = ""; if (null != strInput && strInput.length() > 0) { int endIndex = strInput.lastIndexOf(", "); if (endIndex != -1) { newstr = strInput.substring(0, endIndex); // not forgot to put check if(endIndex != -1) } } return newstr; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.