Home Tutorial Java StringExamples String.equals()

 
 

Share on Google+Share on Google+
String.equals()
Posted on: March 22, 2005 at 12:00 AM
Advertisement
String.equals() method checks the equality between two object and returns in Boolean values.

In Java programming language, equals() is method of string class that is used for comparison between two objects. It always returns the output in Boolean value "true or false". You can use the method to check the equality between the given objects... and the method returns "true" in case of both the objects are equal otherwise it will return "false".

a simple example of equals() method:

public class StringTrim {

public static void main(String[] args) {

String one = "Java Examples";

String two = "Java Examples Code";

String Three = "Java Examples";

String Four = "Java";

System.out.println(one + " is equals to " + two + " -> " + one.equals(two));

System.out.println(one + " is equals to " + Three + " -> " + one.equals(Three));

System.out.println(one + " is equals to " + Four + " -> " + one.equals(Four));

}

}

the output is:

Java Examples is equals to Java Examples Code -> false

Java Examples is equals to Java Examples -> true

Java Examples is equals to Java -> false

Related Examples:
Compare strings example

Advertisement

Related Tags for String.equals():


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 22, 2005

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com