我需要做的就是将每一行中搜索到的单词大写,所以我已经有了`
File myFile = new File("AliceInWonderland.txt");
Scanner scan = new Scanner(myFile);
Scanner uInput = new Scanner(System.in);
String word;
int count = 0;
ArrayList<String> Alice = new ArrayList<String>();
System.out.println("Select the word that you would like to search for, from the book of alice and wonderland: ");
word = uInput.next();
while(scan.hasNext()){
Alice.add(scan.nextLine());
}
for(int i = 0;i <= Alice.size();i++){
if(Alice.get(i).contains(word)){
System.out.println(Alice.get(i));
count++;
}
else{
System.out.println(Alice.get(i));
}
}`
我可以写System.out.println(Alice.get(i).ToUpper);
,但这会将所有带有搜索字词的行大写,我要做的就是突出显示搜索字词