replaceAll(regex, replacement); System.out.println(resultStr); } } Output: JavaisProgramminglanguage As you can see, String’s whicespaces got replaced with "" in the output. That’s all about difference between replace and replaceAll methods in java. Was this post helpful? Let us know ...