Hello anandguna
Originally Posted by
anandguna
use the for loop and iterate the array values
String a="arul";
for (int i = 0; i < arraystring.length(); i++)
if (a == arraystring[i])
System.out.println("match found");
As Norm pointed out, the equality in blue uses to == operator. In Java, if the == operator is used on two variables of object type, like a
String for example, then the test will return true if the variables reference the same object. Otherwise false is obtained. Primitive types, like
int byte boolean or
double, are tested for equality by value, as they are not objects. To test if two strings are equal, use the
boolean String.equals(String other) method. For example:
if (a.equals(arraystring[i])) {
System.out.println("match found");
}
Please ask if you want me to explain more, anandguna.
