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 TypeEncoding
booleanZ
charC
class or interfaceLclassname;
doubleD
floatF
intI
longJ
shortS

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




Latest Courses