getsimplename

类类getSimpleName()方法 (Class class getSimpleName() method)

  • getSimpleName() method is available in java.lang package.

    getSimpleName()方法在java.lang包中可用。

  • getSimpleName() method is used to return the simple name of the underlying class as given in the source code.

    getSimpleName()方法用于返回源代码中给定的基础类的简单名称。

  • getSimpleName() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    getSimpleName()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • getSimpleName() method does not throw an exception at the time of returning the name of classes.

    返回类名称时, getSimpleName()方法不会引发异常。

Syntax:

句法:

    public String getSimpleName();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is String, it returns the following values based on the given cases,

此方法的返回类型为String ,它根据给定的情况返回以下值:

  • It returns the simple name of the class when the underlying class is not anonymous.

    当基础类不是匿名的时,它返回类的简单名称。

  • It returns "" (empty string) when the underlying class is anonymous.

    当基础类为匿名时,它将返回“” (空字符串)。

Example:

例:

// Java program to demonstrate the example
// of String getSimpleName () method of Class
public class GetSimpleNameOfClass {public static void main(String[] args) {// Creating an instance of String
String str = new String();
// It returns the Class object represented by the String class
Class cl = str.getClass();
// It returns the name by using getName() method
String str_name = cl.getName();
System.out.println("String Name :" + str_name);
// It returns simple name by using getSimpleName() method
String str_simple_name = cl.getSimpleName();
System.out.println("String Simple Name :" + str_simple_name);
}
}

Output

输出量

String Name :java.lang.String
String Simple Name :String

翻译自: https://www.includehelp.com/java/class-class-getsimplename-method-with-example.aspx

getsimplename

getsimplename_Java类类getSimpleName()方法的示例相关推荐

  1. java.util.zip 用法,Java压缩文件工具类ZipUtil使用方法代码示例

    本文实例通过Java的Zip输入输出流实现压缩和解压文件,前一部分代码实现获取文件路径,压缩文件名的更改等,具体如下: package com.utility.zip; import java.io. ...

  2. java long valueof_Java Long类的valueOf()方法及示例

    语法:public static Long valueOf (long value); public static Long valueOf (String value); public static ...

  3. Java基础篇:为Box类添加一个方法

    尽管创建一个仅包含数据的类是相当不错的事情,但这样的情况很少发生.大部分情况是你将使用方法存取由类定义的实例变量. 事实上,方法定义大多数类的接口.这允许类实现函数可以把内部数据结构的特定布局隐蔽到方 ...

  4. java的isArray_Java Class类 isArray()方法及示例

    Class类isArray()方法isArray()方法在java.lang包中可用. isArray()方法用于检查此类是否表示数组类. isArray()方法是一个非静态方法,只能通过类对象访问, ...

  5. ulp通信_Java Math类ulp()方法及示例

    ulp通信 数学类ulp()方法 (Math class ulp() method) ulp() method is available in java.lang package. ulp()方法在j ...

  6. Java Math类toDegrees()方法与示例

    数学类toDegrees()方法 (Math class toDegrees() method) toDegrees() method is available in java.lang packag ...

  7. Java类class isAssignableFrom()方法及示例

    类class isAssignableFrom()方法 (Class class isAssignableFrom() method) isAssignableFrom() method is ava ...

  8. java 根据类名示例化类_Java类类getEnclosingClass()方法及示例

    java 根据类名示例化类 类的类getEnclosingClass()方法 (Class class getEnclosingClass() method) getEnclosingClass() ...

  9. java 根据类名示例化类_Java类类getProtectionDomain()方法及示例

    java 根据类名示例化类 类class getProtectionDomain()方法 (Class class getProtectionDomain() method) getProtectio ...

最新文章

  1. python openCV 实现镜像翻转flip()
  2. Solr嵌套子文档的弊端以及一种替代方式
  3. mysql创立不了数据库_以下不属于MySQL安装时自动创建的数据库是( ) (5.0分)_学小易找答案...
  4. 纯干货,Spring-data-jpa详解,全方位介绍。
  5. 流程DEMO-合同会审表
  6. zzulioj 1120: 最值交换
  7. 无法获得 VMCI 驱动程序的版本: 句柄无效。 驱动程序“vmci.sys”的版本不正确。请尝试重新安装 VMware Workstation。 开启模块 DevicePowerOn 的操作失败
  8. OpenCV计算机视觉实战(Python版)_002图像基本操作
  9. 数据结构与算法之循环队列的操作
  10. 学python需要什么基础-零基础学Python应该学习哪些入门知识及学习步骤安排
  11. 扫雷游戏详解——附源码
  12. 做一个网站要多少钱?
  13. Unity之物理引擎
  14. html 库存管理页面,库存管理
  15. 阿里内网疯狂传阅的“M8级”分布式架构笔记,GitHub刚上线就霸榜
  16. 英语四级和计算机二级考试冲突吗,大学必须过英语四级吗?必须过计算机二级吗?...
  17. 美赞臣中国独立后任命朱定平为总裁;思拓凡亚洲首个技术研发卓越中心上海揭幕 | 美通社头条...
  18. HTML登陆界面编程代码
  19. 如何在idea中配置JSTL
  20. speex speexdsp

热门文章

  1. python 当前文件路径获取方式_Python获取当前文件路径
  2. linux课堂笔记(4)
  3. 保留小数点后三位_【Meta分析】Stata制作森林图时,如何保留三位小数?
  4. 企业为什么要做SEO,它的重要性有哪些?
  5. 微信小程序 - 非Form数据怎么发送到后端?
  6. 读书笔记《集体智慧编程》Chapter 2 : Make Recommendations
  7. 【风马一族_xml】xmlp之dtd1
  8. 同事反馈环:如何实现持续改进的文化
  9. .sdp文件格式介绍
  10. 《Oracle comment on注释信息方法论》