Java Class getName() 方法

2025 年 3 月 21 日 | 阅读 2 分钟

Java Class 类的 getName() 方法用于获取实体的名称,该实体可以是类对象所属的类、接口、数组、枚举、方法等。

元素类型编码
booleanZ
charC
类或接口Lclassname;
doubleD
floatF
intI
longJ
shortS

语法

参数

不适用

返回值

实体名称(字符串格式)。

抛出

不抛出异常。

示例 1

输出

The Class Name = ClassgetNameExample1

示例 2

输出

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
 
下一个主题Java类