java - Is there any functions in String which can to help delete all spaces in string? -
is there functions in string
can delete spaces in string? wouldn't use method this.
private string deletespace(string string) { string newstring = ""; for(int = 0;i < string.length();i++) if(string.charat(i) != ' ') newstring += string.valueof(string.charat(i)); return newstring; }
thank help.
// occurrences literal arguments string = string.replace(" ","");
or
// occurrences regular expression arguments string = string.replaceall("\\s+", "");
Comments
Post a Comment