Saturday, 7 March 2015

Equals Method in JAVA

Description:

This method compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.

Syntax:

Here is the syntax of this method:
public boolean equals(object anObject)


Examples:

class eql
{
    public static void main(String args[])
{
    String x="NIIT";
    String y="NIIT";
    if(x.equals(y))
{
    System.out.println("Equals");
}
   else
{
System.out.println("Not Equal");
}
}
}

Sample Output :    Equals

No comments:

Post a Comment