[Bluej-discuss] Exercise 4.19 from the book....
Vivie
emor at it.teithe.gr
Fri Aug 11 18:56:04 BST 2006
Hello....
I am studuying the book on my own and I have this question....
in project Notebook1, I am trying to do exercise 4.19 , with the
iteration...
I thought the program when we execute the search , would print only one
string...either the note that was found , or that it wasn't....
but I saw it prints them both!! what's wrong with my code?
I include the code...
public void search(String searchString)
{
int index = 0;
boolean found = false;
while(index < notes.size() && !found) {
String note = notes.get(index);
if(note.contains(searchString)) {
found = true;
System.out.println(note);
}
else {
System.out.println("Search term not found.");
index++;
}
}
}
More information about the bluej-discuss
mailing list