Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java string matching problem

Tags:

java

I am facing a very basic problem. Some time small things can take your whole day :( but thank to stackoverflow memebers who always try to help :)

I am trying to match 2 strings if they match it should return TRUE

now I am using this

if (var1.indexOf(var2) >= 0) {
return true;
}

But if var1 has value "maintain" and var2 has value "inta" or "ain" etc. it still return true :(. Is there any way in java that can do full text matching not partial? For example

if("mango"=="mango"){
return true;
}

thanks ! ! !

like image 544
user238384 Avatar asked Jun 22 '26 00:06

user238384


1 Answers

Why not just use the built-in String equals() method?

return var1.equals(var2);
like image 65
hbw Avatar answered Jun 24 '26 12:06

hbw