The 's' replaces just one Room match at any given time even so the 's+' replaces the whole Area sequence without delay with the second parameter.However x.replaceAll("s+", ""); is going to be extra effective method of trimming spaces (if string can have numerous contiguous Areas) because of probably less no of replacements thanks the to proven fact