contains(): This method is available in java.nio.charset.Charset class of Java.
Syntax:
boolean java.nio.charset.Charset.contains(Charset cs)
This method takes one argument of type Charset as its parameter. This method tells whether or not this charset contains the given charset.
Note: A charset C is said to contain a charset D if, and only if, every character representable in D is also representable in C.
Parameters: One parameter is required for this method.
cs: The given charset
Returns: true if the given charset is contained in this charset.
For Example:
Charset cs = Charset.forName("UTF-8")
Charset cs2 = Charset.forName("UTF-8")
cs.contains(cs2) = > It returns true.
Approach
Java
import java.nio.charset.Charset;public class CharsetContains {public static void main(String[] args) {Charset cs = Charset.forName("UTF-8");Charset cs2 = Charset.forName("UTF-8");System.out.println(cs.contains(cs2));}}
Output:
true
No comments:
Post a Comment