Charset displayName() in Java

displayName(): This method is available in java.nio.charset.Charset class of Java.

Syntax:

String java.nio.charset.Charset.displayName()

This method returns this charset's human-readable name for the default locale. The default implementation of this method simply returns this charset's canonical name.

Parameters: NA

Returns: The display name of this charset in the default locale.

For Example:

Charset cs = Charset.forName("UTF-8")

cs.displayName() = > It returns UTF-8

Approach

Java

import java.nio.charset.Charset;

public class CharsetdisplayName {
    public static void main(String[] args) {

        Charset cs = Charset.forName("UTF-8");

        System.out.println(cs.displayName());
    }

}

Output:

UTF-8

No comments:

Post a Comment