Charset equals() method in Java with Examples Last Updated : 01 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: public final boolean equals(Object other) Parameters: The function accepts a single mandatory parameter other which specifies the reference object with which it is compared with. Return Value: The function returns a boolean value. It returns true if it is equal, else it returns false. Below is the implementation of the above function: Program 1: Java // Java program to demonstrate // the above function import java.nio.charset.Charset; import java.util.Iterator; import java.util.Map; public class GFG { public static void main(String[] args) { // First charset Charset first = Charset.forName("ISO-2022-CN"); // Second charset Charset second = Charset.forName("UTF-8"); System.out.println(first.equals(second)); } } Output: false Program 2: Java // Java program to demonstrate // the above function import java.nio.charset.Charset; import java.util.Iterator; import java.util.Map; public class GFG { public static void main(String[] args) { // First charset Charset first = Charset.forName("UTF-8"); // Second charset Charset second = Charset.forName("UTF-8"); System.out.println(first.equals(second)); } } Output: true Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/Charset.html#equals-java.lang.Object- Comment More infoAdvertise with us Next Article Charset equals() method in Java with Examples G gopaldave Follow Improve Article Tags : Java Java-Functions Java-NIO package Java-Charset Practice Tags : Java Similar Reads Character.equals() method in Java with examples 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 2 min read BitSet equals() Method in Java with Examples The equals() method of Java BitSet class is used to check for equality between two bitsets. It verifies whether the elements of one set passed as a parameter is equal to the elements of this set or not. The method returns true if the bitsets match else false. Syntax: Bit_Set1.equals(Bit_Set2) Parame 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 Java File Class equals() Method with Examples The equals() method of Java File Class compares the pathname supplied in the argument to the pathname provided in the argument. If the parameter is not null and points to the same file or directory, this function returns true. The operating system determines if the two abstract pathnames are equival 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