Writer getClass() method in Java with Examples Last Updated : 29 May, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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(); Parameters: This method accepts does not accepts any parameter. Return Value: This method returns the Class details which is the parent Class of the Writer instance. Note: The Object class is the superclass for all the classes in Java. Hence, every class can implement the getClass() method. Examples of the Writer getClass() method The below methods illustrate the working of the getClass() method: Example 1 Java // Java program to demonstrate // Writer getClass() method import java.io.*; // Driver Class class GFG { // main function public static void main(String[] args) { try { // Create a Writer instance Writer writer = new PrintWriter(System.out); // 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); } } } OutputParent Class: class java.io.PrintWriter Example 2 Java // Java program to demonstrate // Writer getClass() method import java.io.*; // Driver Class class GFG { // main function public static void main(String[] args) { try { // Create a Writer instance Writer writer = new OutputStreamWriter(System.out); // 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); } } } OutputParent Class: class java.io.OutputStreamWriter Comment More infoAdvertise with us Next Article Writer getClass() method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-IO package Java-Writer Practice Tags : Java Similar Reads StringWriter getClass() method in Java with Examples 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 para 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 Writer write(int) method in Java with Examples The write(int) method of Writer Class in Java is used to write the specified byte value on the writer. This byte value is specified using the ASCII value of the byte value passed as an integer value. This integer value is taken as a parameter. Syntax: public void write(int ascii) Parameters: This me 2 min read Class getSuperclass() method in Java with Examples The getSuperclass() method of java.lang.Class class is used to get the super class of this entity. This entity can be a class, an array, an interface, etc. The method returns the super class of this entity.Syntax: public Class<T> getSuperclass() Parameter: This method does not accept any param 2 min read Class getClassLoader() method in Java with Examples The getClassLoader() method of java.lang.Class class is used to get the classLoader of this entity. This entity can be a class, an array, an interface, etc. The method returns the classLoader of this entity.Syntax: public ClassLoader getClassLoader() Parameter: This method does not accept any parame 1 min read Like