Apologies for the total noob question, but can anyone explain what's happening to the value of match after the for-each loop has finished in the following method?
Attempts to compile produce the warning: variable match might not have been initialised.
public void listMatching(String searchString) {
boolean match;
for(String filename : files) {
if(filename.contains(searchString)) {
System.out.println(filename);
match = true;
}
else {
match = false;
}
}
if(match == false) {
System.out.println("No matches found for " + searchString);
}
}