Charset toString() method in Java with Examples Last Updated : 28 Mar, 2019 Comments Improve Suggest changes Like Article Like Report The toString() method is a built-in method of the java.nio.charset returns a string which describes the charset involved. Syntax: public final String toString() Parameters: The function does not accepts any parameter. Return Value: The function returns a string describing this charset. 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.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; public class GFG { public static void main(String[] args) { // Gets charset Charset Charset1 = Charset.forName("UTF8"); // Print System.out.println(Charset1.toString()); } } Output: UTF-8 Program 2: Java // Java program to demonstrate // the above function import java.nio.charset.Charset; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; public class GFG { public static void main(String[] args) { // Gets charset Charset Charset1 = Charset.forName("UTF16"); // Print System.out.println(Charset1.toString()); } } Output: UTF-16 Reference: https://docs.oracle.com/javase/9/docs/api/java/nio/charset/Charset.html#toString-- Comment More infoAdvertise with us Next Article Charset toString() method in Java with Examples gopaldave Follow Improve Article Tags : Java Java-Functions Java-NIO package Java-Charset Practice Tags : Java Similar Reads Class toString() method in Java with Examples The toString() method of java.lang.Class class is used to convert the instance of this Class to a string representation. This method returns the formed string representation. Syntax: public String toString() Parameter: This method does not accept any parameter. Return Value: This method returns the 1 min read Date toString() method in Java with Examples The toString() method of Java Date class converts this date object into a String in form "dow mon dd hh:mm:ss zzz yyy". This method overrides toString in class object. Syntax: public String toString() Parameters: The function does not accept any parameter. Return Value: It method returns a string re 2 min read Byte toString() method in Java with examples The toString() method of Byte class is a built in method in Java which is used to return a String value. public String toString() Syntax: ByteObject.toString() Return Value: It returns a String object, the value of which is equal to the value of the ByteObject. Below is the implementation of toStrin 2 min read Currency toString() Method in Java with Examples The toString() Method of Currency class in Java is used to retrieve the currency code of this currency which is actually the official ISO 4217 currency code in a string format Syntax: CURRENCY.toString() Parameters: This method does not accept any parameters. Return Value: This method returns the IS 2 min read AbstractSet toString() method in Java with Example The toString() method of Java AbstractSet is used to return a string representation of the elements of the Collection. The String representation comprises a set representation of the elements of the Collection in the order they are picked by the iterator closed in square brackets[].This method is us 2 min read Calendar toString() Method in Java with Examples The toString() method in Calendar class is used to get the string representation of the Calendar object. This method in Calendar Class is just for debug process and not to be used as an operation. Syntax: public String toString() Parameters: The method does not take any parameters. Return Value: The 1 min read CharArrayWriter toString() method in Java with examples The toString() method of the CharArrayWriter class in Java converts the given input data to a string. Syntax: public String[] toString() Parameters: This method does not accept any parameter. Return Value: This method returns a copy of the input data. Below program illustrate the above method: Progr 1 min read Duration toString() method in Java with Examples The toString() method of Duration Class in java.time package is used to get the String value of this duration. This String is in the ISO-8601 format. Syntax: public String toString() Parameters: This method do not accepts any parameter. Return Value: This method returns a String value which is the S 1 min read Constructor toString() method in Java with Examples The toString() method of java.lang.reflect.Constructor class is used to return string representation of this Constructor.This string is the collection of all the properties of this constructor. For creating this string method adds access modifiers of the constructor with the name of the declaring cl 2 min read Like