The 's' replaces a person space match at a time however the 's+' replaces The complete space sequence at the same time with the second parameter.Nonetheless x.replaceAll("s+", ""); might be extra economical means of trimming spaces (if string can have multiple contiguous Areas) for the reason that of probably a lot less no of replacements owing the