import java.util.Scanner; import java.lang.String; public class Main { public static void main(String[] args) { String string = "H e l l o ! n o w c o d e r"; Scanner scanner= new Scanner(System.in); String word = scanner.next(); scanner.close(); System.out.println(check(string, word)); } public static int check(String str, String word) { //write your code here...... String newStr=str.replace(word,"xx"); //替换 return newStr.length()-str.length();//用替换的长度-原长度 } }