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

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -