CompositeName equals() method in Java with Examples
The equals() method of a javax.naming.CompositeName class is used to compare this CompositeName with the specified object passed as a parameter and checks whether two objects are equal or not. If both objects are equal then the equals() method returns true else false. If passed obj is null or not a composite name then the method returns false. Two composite objects are equal if each component in one is equal to the corresponding component in the other.
public boolean equals(Object obj)
Parameters: This method accepts obj which is the possibly null object to compare against.
Return value: This method returns true if obj is equal to this composite name, false otherwise.
Below programs illustrate the CompositeName.equals() method:
CompositeName1 is equal to CompositeName2
CompositeName1 is not equal to CompositeName2
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.