Java String Function equals()

The java string equals() method compares the two given strings based on the content of the string. If any character is not matched, it returns false. If all characters are matched, it returns true.
The String equals() method overrides the equals() method of Object class.

Java String equals() method example

public class EqualsExample{  
public static void main(String args[]){  
String s1="efaculty";  
String s2="efaculty";  
String s3="EFACULTY";  
String s4="java";  
System.out.println(s1.equals(s2));//true because content and case is same  
System.out.println(s1.equals(s3));//false because case is not same  
System.out.println(s1.equals(s4));//false because content is not same  
}}   


Output:

true
false
false
java java string