在“abcdefghigklmnopqrstuvwxyz"中去掉用户输入的关键字,我的代码如下:privateStringremoveKeyword(StringmodifiedKeyword){intwordLength=modifiedKeyword.length();intletterPos...
在“abcdefghigklmnopqrstuvwxyz"中去掉用户输入的关键字,我的代码如下:
private String removeKeyword(String modifiedKeyword){
int wordLength = modifiedKeyword.length();
int letterPosition;
int alphabetPosition;
String modifiedAlphabet = "";
final String PLAIN_ALPHA = "bcdefghijklmnopqrstuvwxyz";
for (alphabetPosition = 0; alphabetPosition <= 26; alphabetPosition++){
boolean shouldBeDeleted = false;
char alphabetLetter = PLAIN_ALPHA.charAt(alphabetPosition);
for (letterPosition = 0; letterPosition > wordLength; letterPosition++){
char keywordLetter = modifiedKeyword.charAt(letterPosition);
if (alphabetLetter == keywordLetter) {
shouldBeDeleted = true;
}
modifiedAlphabet = alphabetLetter + modifiedAlphabet;
}
}
return modifiedAlphabet;
}
但是在第八行,弹出一个warning : Warning: The local variable shouldBeDeleted is never read
请问应该怎么解决?不胜感激
展开