import java.awt.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Test_Pratice {
public static void main(String[] args) {
List li = new ArrayList();
li.add("飞虎队");
li.add("突击队");
li.add("皓龙队");
li.add("一对");
Scanner sc = new Scanner(System.in);
System.out.print("请用户输入一个名字:");
String contance = sc.nextLine();
for (int i = 0; i < li.size(); i++) {
String word = li.get(i).toString();
if (contance.contains(word)) {
String s = "";
for (int j = 0; j < word.length(); j++) {
s += "*";
}
contance = contance.replace(word,s);
}
}
System.out.println(contance);
|