equals(): This method is available in java.lang.Object class of Java.
Syntax:
boolean java.lang.Character.equals(Object obj)
This method takes one argument of type Object( Character, String, Integer, etc) as its parameter. This method compares this object against the specified object. The result is true if and only if the argument is not null and is a Character object that represents the same char value as this object.
Parameters: One parameter is required for this method.
obj: the object to compare with.
Returns: true if the objects are the same; false otherwise.
Exceptions: NA
Approach
Java
public class Characterequals {public static void main(String[] args) {Character c = 'a';Character obj = 'a';System.out.println(c.equals(obj));}}
Output:
true
No comments:
Post a Comment