0
Well I have a vector that gets several lines of text. But I need to compare these lines and see if I can find a word, I tried it with equals() but it only returns true if it finds exactly the same string and contains() does not work with the vector. ex:
Word I want to seek: tomato
vector text:
[0] = Lettuces are green.
[1] = Os tomatos are red.
[2] = Peppers are coloured.
I left the code like this. It returns me the line in which is the word searched which already serves for my goals.
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 in advance for your attention to me.
Thanks for helping!
– Raytek