Here you can find the source of removeMinusChar(String str)
public static String removeMinusChar(String str)
//package com.java2s; public class Main { public static String removeMinusChar(String str) { return remove(str, '-'); }//from w w w . j a va 2 s.c o m public static String remove(String str, char remove) { if (isEmpty(str) || str.indexOf(remove) == -1) { return str; } char[] chars = str.toCharArray(); int pos = 0; for (int i = 0; i < chars.length; i++) { if (chars[i] != remove) { chars[pos++] = chars[i]; } } return new String(chars, 0, pos); } public static boolean isEmpty(String str) { return str == null || str.length() == 0; } public static int indexOf(String str, String searchStr) { if (str == null || searchStr == null) { return -1; } return str.indexOf(searchStr); } }