我需要什么来代替 ""来用 * 替换所有字母?
public static void main(String[] args) {
String s = "Tere, TULNUKAS, 1234!";
String t = asenda(s); // "****, ********, 12345!" <---- example
}
public static String asenda(String s) {
return s.replaceAll("", "*");
}
谢谢!
最佳答案
你必须使用正则表达式:
return s.replaceAll("[a-zA-z]", "*")
关于java - replaceAll,如何改变字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21113641/