I try to find a book by its title.
Let's say the book "Jungle" exists. I want to find it even if I search for
- "JunGLE" : works,
- "Jung" : works,
- "JunG" : does not work.
I hope you understand. I use matches
to add all the books that matches that title in the search. Does anyone know how to fix this?
public ArrayList<Book> search(String title){
ArrayList<Book> matches = new ArrayList<>();
for (Book b : Books){
String s = b.getTitle();
if(s.equalsIgnoreCase(title)||s.trim().contains(title))
matches.add(b);
}
return matches;
}