Java String.replace无效

这是我的代码。

String x = "1+√10"; x = x.replace(".*", "x"); System.out.println(x); 

这应该返回"x"但是它返回"1+√10" 。 为什么这不起作用?

String#replace不支持正则表达式,使用String#replaceAll

 x = x.replaceAll(".+", "x");