Well I have a vector that gets several lines of text. But I need to compare these lines and see if I find a word, I tried with equals () but it only returns true if it finds exactly the same string and contains () does not work with the vector. ex:
Word that I want to search for: tomato
vector text:
[0] = Lettuces are green.
[1] = The tomatoes are red.
[2] = Peppers are colorful.
I left the code like this. It returns me the line where the word is found which already serves my purposes.
public int buscaLinha(String[] vetor, String palavra)
{
int i = 1;
for(String p : vetor)
{
if(p.contains(palavra)) {
return i;
}
i++;
}
return 0;
}
I would like to thank you for the attention you have given me.