1
當我運行程序時,它保持運行並且控制檯處於活動狀態以便輸入,所以我必須停止。這是爲什麼? (要在句子中找到鏡像詞。使用INTELIJ IDEA)。彙編繼續運行(模式,匹配器任務)
public class Blinov11 {
static String mirror(String str){
String mirrored = "";
for (int i = str.length() - 1; i >= 0; i--) {
mirrored += str.charAt(i);
}
return mirrored;
}
public static void main(String[] args) {
String text = new String("If the method atad fi takes data a sekat takes primitive data type as an argument, then the nhet String object representing the primitive data type value is return.");
Pattern pattern = Pattern.compile("\\W\\w+\\W",Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(text);
String word = "";
while(matcher.find()){
word = mirror(matcher.group());
if(text.contains(word)){
System.out.println(word);
}
matcher.reset();
}
}
}