Character.equals() method in Java with examples Last Updated : 06 Dec, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The java.lang.Character.equals() is a function in Java which compares this object against the specified object. If the argument is not null then the result is true and is a Character object that represents the same char value as this object. Syntax: public boolean equals(Object obj) Parameters: The function accepts a single parameter obj which specifies the object to be compared with. Return Value: The function returns a boolean value. It returns true if the objects are same, otherwise, it returns false. Below programs illustrates the above method: Program 1: Java // Java program to demonstrate the function // Character.equals() when two objects are same import java.lang.*; public class gfg { public static void main(String[] args) { // assign values to c1, c2 Character c1 = new Character('Z'); Character c2 = new Character('Z'); // assign the result of equals method on c1, c2 to res boolean res = c1.equals(c2); // print res value System.out.println(c1 + " and " + c2 + " are equal is " + res); } } Output: Z and Z are equal is true Program 2: Java // Java program to demonstrate function // when two objects are different import java.lang.*; public class gfg { public static void main(String[] args) { // assign values to c1, c2 Character c1 = new Character('a'); Character c2 = new Character('A'); // assign the result of equals // method on c1, c2 to res boolean res = c1.equals(c2); // prints the res value System.out.println(c1 + " and " + c2 + " are equal is " + res); } } Output: a and A are equal is false Reference: https://docs.oracle.com/javase/7/docs/api/java/lang/Character.html#equals(java.lang.Object) Comment More infoAdvertise with us Next Article Character.equals() method in Java with examples T Twinkl Bajaj Follow Improve Article Tags : Misc Java Java-lang package Java-Functions Java-Character +1 More Practice Tags : JavaMisc Similar Reads Charset equals() method in Java with Examples The equals() method is a built-in method of the java.nio.charset checks if a given object of charset is equal to another given object of the charset. Two charsets are considered equal if, and only if, they have the same canonical names. A charset is never equal to any other type of object. Syntax: p 2 min read Byte equals() method in Java with examples The equals() method of Byte class is a built in method in Java which is used to compare the equality given Object with the instance of Byte invoking the equals() method. Syntax ByteObject.equals(Object a) Parameters: It takes an Object type object a as input which is to be compared with the instance 2 min read AbstractMap equals() Method in Java with Examples The equals() method of the Java AbstractMap class is used to check equality between two maps. It compares the key-value pair in the current map with the key-value pair of the specified map.Syntax of AbstarctMap equals() Methodpublic boolean equals(Object o)Parameter: The Object to be compared with t 2 min read Constructor equals() method in Java with Examples The constructor class provides information about a single constructor for a class and it also provides access to that constructor. The equals() method of java.lang.reflect.Constructor is used to compare this Constructor against the passed object. If the objects are the same then the method returns t 2 min read AbstractList equals() method in Java with Examples The equals() method of java.util.AbstractList class is used to compare the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e 3 min read Like