Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Field toGenericString() method in Java with Examples
Next article icon

Class toGenericString() method in Java with Examples

Last Updated : 27 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The toGenericString() method of java.lang.Class class is used to convert the instance of this Class to a string representation along with the information about the modifiers and type parameters. This method returns the formed string representation. Syntax:
  public String toGenericString()  
Parameter: This method does not accept any parameter. Return Value: This method returns the String representation of this object. Below programs demonstrate the toGenericString() method. Example 1: Java
// Java program to demonstrate toGenericString() method  public class Test {     public static void main(String[] args)         throws ClassNotFoundException     {         // returns the Class object for the class         // with the specified name         Class c1 = Class.forName("java.lang.String");          System.out.print("Class represented by c1: ");          // toGenericString method on c1         System.out.println(c1.toGenericString());     } } 
Output:
  Class represented by c1: public final class java.lang.String  
Example 2: Java
// Java program to demonstrate toGenericString() method  public class Test {     public static void main(String[] args)         throws ClassNotFoundException     {         // returns the Class object for the class         // with the specified name         Class c2 = int.class;         Class c3 = void.class;          System.out.print("Class represented by c2: ");          // toGenericString method on c2         System.out.println(c2.toGenericString());          System.out.print("Class represented by c3: ");          // toGenericString method on c3         System.out.println(c3.toGenericString());     } } 
Output:
  Class represented by c2: int  Class represented by c3: void  
Reference: https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html#toGenericString--

Next Article
Field toGenericString() method in Java with Examples

S

srinam
Improve
Article Tags :
  • Java
  • Java-lang package
  • Java-Functions
  • Java.lang.Class
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
  • Constructor toGenericString() method in Java with Examples
    The toGenericString() method of java.lang.reflect.Constructor class is used to return get the generic form of this constructor, i.e. a string representing the details about this constructor including the type parameters. Syntax: public String toGenericString() Parameters: This method accepts nothing
    2 min read
  • Field toGenericString() method in Java with Examples
    The toGenericString() method of java.lang.reflect.Field is used to return a string which represents this Field, including its generic type. The format of the string is the access modifiers for the field, if any, followed by the generic field type, followed by a space, followed by the fully-qualified
    2 min read
  • Charset toString() method in Java with Examples
    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
    1 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
  • 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
  • Bidi toString() method in Java with Examples
    The toString() method of java.text.Bidi class is used to display this Bidi instance in string representation. Syntax: public String toString() Parameter: This method accepts nothing as parameter. Return Value: This method display internal state of bidi in string format. Below are the examples to ill
    2 min read
  • BigDecimal toEngineeringString() Method in Java with Examples
    The java.math.BigDecimal.toEngineeringString() method is used to represent the current BigDecimal by which this method is called into String form by using engineering notation if an exponent is needed. The string representation of the BigDecimal is the same as described in the toString() method, exc
    2 min read
  • BigDecimal toString() Method in Java with Examples
    The java.math.BigDecimal.toString() method is used to represent the current BigDecimal by which this method is called into String form, using scientific notation if an exponent is needed. It is done by following steps: A standard canonical string form of the BigDecimal is created by converting the a
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences