Close

Java Reflection - Class.toGenericString() Examples

Code Snippets Java Reflection Java Java API 


Class:

java.lang.Class

java.lang.Objectjava.lang.Objectjava.lang.Classjava.lang.Classjava.io.SerializableSerializablejava.lang.reflect.GenericDeclarationGenericDeclarationjava.lang.reflect.TypeTypejava.lang.reflect.AnnotatedElementAnnotatedElementLogicBig

Method:

public String toGenericString()
Returns:

a string describing this Class , including information about modifiers and type parameters


Examples


package com.logicbig.example.clazz;

public class ToGenericStringExample {

public static void main(String... args) {
String s = String.class.toGenericString();
System.out.println(s);
}
}

Output

public final class java.lang.String




package com.logicbig.example.clazz;

public class ToGenericStringExample2 {

public static void main(String... args) {
String s = Runnable.class.toGenericString();
System.out.println(s);

s = Deprecated.class.toGenericString();
System.out.println(s);
}
}

Output

public abstract interface java.lang.Runnable
public abstract @interface java.lang.Deprecated




package com.logicbig.example.clazz;

public class ToGenericStringExample3 {

public static void main(String... args) {
String s = int.class.toGenericString();
System.out.println(s);

s = int[].class.toGenericString();
System.out.println(s);

s = void.class.toGenericString();
System.out.println(s);
}
}

Output

int
int[]
void




See Also