String srt="abc?abc"; str.replaceAll("?", "#"); 会提示这样的错误 Dangling meta character '?' near index 0 ? ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.sequence(Unknown Source) at java.util.regex.Pattern.expr(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern.<init>(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.lang.String.replaceAll(Unknown Source) str.replaceAll("[?]", "#"); 这样写就可以了