Java equals() Method


The String equals() method is used to compare two strings for equality. If the given strings contain the same characters it returns true otherwise return false.

 

Syntax:

boolean equals(Object str) 

Example:

 public class Equalsmethod{  
	public static void main(String args[]){  
        String s1="Onlinetpoint"; 
        String s2="Onlinetpoint"; 
        System.out.println(s1.equals(s2)); //equals method 
    }
}



Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.