Javatpoint Logo
Javatpoint Logo

Java Class getName() Method

The getName() method of java Class class is used to get the name of the entity, and that entity can be class, interface, array, enum, method, etc. of the class object.

Element Type Encoding
boolean Z
char C
class or interface Lclassname;
double D
float F
int I
long J
short S

Syntax

Parameter

NA

Returns

Entity name as the string.

Throws

Does not throw an exception.

Example 1

Test it Now

Output:

The Class Name = ClassgetNameExample1

Example 2

Test it Now

Output:

Name of the method: main
Name of the method: setManyValuesMethod
Name of the method: setValueMethod
Name of the method: getValueMethod
Name of the method: wait
Name of the method: wait
Name of the method: wait
Name of the method: equals
Name of the method: toString
Name of the method: hashCode
Name of the method: getClass
Name of the method: notify
Name of the method: notifyAll

Next TopicJava Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA