equals(): This method is available in java.nio.charset.Charset class of Java.
Syntax:
boolean java.nio.charset.Charset.equals(Object ob)
This method takes one argument of type Object as its parameter. This method tells whether or not this object is equal to another.
Note: Two charsets are equal if, and only if, they have the same canonical names. A charset is never equal to any other type of object.
Parameters: One parameter is required for this method.
ob: the reference object with which to compare.
Returns: true if, and only if, this charset is equal to the given object.
For Example:
Charset cs = Charset.forName("UTF-8")
Charset ob = Charset.forName("UTF-8")
cs.equals(ob) = > It returns true.
Approach
Java
import java.nio.charset.Charset;public class Charsetequals {public static void main(String[] args) {Charset cs = Charset.forName("UTF-8");Charset ob = Charset.forName("UTF-8");System.out.println(cs.equals(ob));}}
Output:
true
No comments:
Post a Comment