The
newEncoder() method is a built-in method of the
java.nio.charset constructs a new encoder for this charset.
Syntax:
public abstract CharsetEncoder newEncoder()
Parameters: The function does not accepts any parameter.
Return Value: The function returns a new encoder for this charset
Errors and Exceptions: The function throws
UnsupportedOperationException if the charset does not supports encoding.
Below is the implementation of the above function:
Program 1:
Output:
sun.nio.cs.UTF_8$Encoder@232204a1
Program2: