StringWriter getClass() method in Java with Examples Last Updated : 21 Jun, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The getClass() method of StringWriter Class in Java is used to get the parent Class of this StringWriter instance. This method does not accepts any parameter and returns the required Class details. Syntax: public final Class String getClass() Parameters: This method accepts does not accepts any parameter. Return Value: This method returns the Class details which is the parent Class of the StringWriter instance. Below methods illustrates the working of getClass() method: Program 1: Java // Java program to demonstrate // StringWriter getClass() method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a StringWriter instance StringWriter writer = new StringWriter(); // Get the String // to be written in the stream String string = "GeeksForGeeks"; // Write the string // to this writer using write() method writer.write(string); // Get Class details using getClass() System.out.println("Parent Class: " + writer.getClass()); } catch (Exception e) { System.out.println(e); } } } Output: Parent Class: class java.io.StringWriter Program 2: Java // Java program to demonstrate // StringWriter getClass() method import java.io.*; class GFG { public static void main(String[] args) { try { // Create a StringWriter instance StringWriter writer = new StringWriter(); // Get the String // to be written in the stream String string = "GFG"; // Write the string // to this writer using write() method writer.write(string); // Get Class details using getClass() System.out.println("Parent Class: " + writer.getClass()); } catch (Exception e) { System.out.println(e); } } } Output: Parent Class: class java.io.StringWriter Comment More infoAdvertise with us Next Article StringWriter getClass() method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-IO package Java-StringWriter Practice Tags : Java Similar Reads Writer getClass() method in Java with Examples The getClass() method of Writer Class in Java is used to get the parent Class of this Writer instance. This method does not accept any parameter and returns the required Class details. Syntax of getClass() methodpublic final Class String getClass()Calling of the getClass() methodobject_name.getClass 2 min read Provider.Service getClassName() method in Java with Examples The getClassName() method of java.security.Provider.Service class is used to return the specified name of the class utilizing its provider service. Syntax: public final String getClassName() Return Value: This method returns specified name of the class. Below are the examples to illustrate the getCl 2 min read Class getClasses() method in Java with Examples The getClasses() method of java.lang.Class class is used to get the classes of this class, which are the class and interfaces that are public and its members. The method returns the classes of this class in the form of array of Class objects. Syntax: public Class[] getClasses() Parameter: This metho 2 min read Package getPackages() method in Java with Examples The getPackages() method of java.lang.Package class is used to get the Packages defined by the caller's class loader. The method returns the packages as an array of Package objects. Syntax: public boolean getPackages(String desiredVersion) Parameter: This method does not accept any parameter. Return 3 min read Package getName() method in Java with Examples The getName() method of java.lang.Package class is used to get the name of this package. The method returns the name of the package as a String.Syntax: public String getName() Parameter: This method does not accept any parameter.Return Value: This method returns the name of the package as a String.B 2 min read Like