Often beginners use string.replaceAll(" ", "") and even string.replaceAll("\\s", "") doesn't work properly, as Java's implementation of regex doesn't cover all the whitespaces (as per this stackoverflow)
So a method that relies on Character.isWhiteSpace is an improvement, can be used as method reference and also performs better.
replaceAll is evil. For example, "/some/filepath".replaceAll("/", java.io.File.separator) does not work on Windows. Github issues are full of such error reports.
55
u/TheRedmanCometh Sep 19 '18
Holy shit isBlank should have existed long ago. Strip though is just replace without parameters