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. Ril分析三——客户端请求和响应处理与modem交互
  2. 最好的编程名言,大家一起来共勉----转载
  3. [异能程序员]第五章 出手(第一更)
  4. 专家:番茄花园洪磊最高可判刑7年
  5. JS实现的一个验证码,可以在前端验证后在提交action
  6. Handler学习总结
  7. mysql unrecognized service问题解决
  8. vs2017 html安装,解决vs2017无法安装问题
  9. WPS 页码设置为(前1...前3,后4...后6)
  10. 【pwnable.kr】 mistake
  11. 数学建模:地貌图的完成
  12. 大数据技术怎么自学?大数据开发如何自学?
  13. MFC二叉树可视化绘制 (C++)—— 插入、删除、先序遍历、中序遍历、后序遍历、层序遍历(基于平衡二叉树实现)
  14. JavaSE之异常处理
  15. Android开发经验谈-很少有人会告诉你的Android开发基本常识,经验谈android
  16. UiPath的下载安装与基本使用
  17. ArcMap 导入 wrl_一键同步!CODING 现已支持导入 GitHub 仓库
  18. MySQL中文参考手册--1.MySQL的一般信息
  19. Huffman(哈夫曼)编码及java实现
  20. java thread monitor_java并发系列-monitor机制实现

热门文章

  1. oracle dbf 超大,oracle 数据库users01.dbf文件过大 转移方法
  2. 的setinterval函数_ES6 极简教程 lt;6gt; 函数扩展
  3. microbit编程_使用图形化编程实现主控板与手机蓝牙通讯(2019.3.25)
  4. python人脸识别源码_Python 抖音机器人,让你找到漂亮小姐姐
  5. 二本考北航计算机经历,我(来自二本学校)考上北航的一些经历
  6. android sdk是灰的,Android Studio 2.3 sdk管理器标签灰显
  7. linux命令之history命令
  8. 【51CTO学院】搜索V2.0——新的搜索,只为给你更好的
  9. 李洪强iOS开发之FMDB线程安全的用法
  10. 手机站点击商务通无轨迹解决方法