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

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

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

  • getComponentType() method is used to returns the Class denoting the component type of an array.

    getComponentType()方法用于返回表示数组的组件类型的Class。

  • getComponentType() 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.

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

  • getComponentType() method does not throw an exception at the time of returning Class.

    返回Class时, getComponentType()方法不会引发异常。

Syntax:

句法:

    public Class getComponentType();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of this method is Class, it returns the component type in terms of "Class" type.

该方法的返回类型为Class ,它以“ Class”类型的形式返回组件类型。

Example:

例:

// Java program to demonstrate the example
// of Class getComponentType() method of Class
public class GetComponentTypeOfClass {public static void main(String[] args) {// Creating an array of Integer type
Integer[] num = new Integer[] {10,
20,
30
};
// It returnd the Class denoting the component type
Class cl = num.getClass();
// By using getComponentType() method is used to
// get the component of the given Class
Class comp_type = cl.getComponentType();
// If any component exists
if (comp_type != null)
System.out.println("Component Type: " + comp_type);
else
System.out.println("No Component Type Associated");
}
}

Output

输出量

Component Type: class java.lang.Integer

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

Java类类getComponentType()方法与示例相关推荐

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

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

  2. java散列法的运用实例,Java HashMap compute() 使用方法及示例

    Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...

  3. math的用法在java中的使用,Java Math cbrt() 使用方法及示例

    Java Math cbrt() 使用方法及示例 Java Math cbrt()方法返回指定数字的立方根. cbrt()方法的语法为: Math.cbrt(double num) 注意:cbrt() ...

  4. java arraylist 方法返回值,Java ArrayList get() 使用方法及示例

    Java ArrayList get() 使用方法及示例 Java ArrayList get()方法返回指定位置存在的元素. get()方法的语法为: arraylist.get(int index ...

  5. java kryo_Kryo框架使用方法代码示例

    Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...

  6. java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例

    import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...

  7. java invalidate_Java Component.invalidate方法代码示例

    import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...

  8. java hasmoreelements_Java IOException.hasMoreElements方法代码示例

    import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...

  9. java singletonlist_Java Collections singletonList()方法及示例

    集合类singletonList()方法 (Collections Class singletonList() method) singletonList() method is available ...

  10. Java Math toIntExact() 使用方法及示例 long转int

    Java Math toIntExact()方法从指定的long参数返回int值. toIntExact()方法的语法为: Math.toIntExact(long value) 注意:toIntEx ...

最新文章

  1. 黑盒测试之等价类测试
  2. Andrew Gelman、Aki Vehtari​ | 过去50年最重要的统计学思想是什么?
  3. Celery - 一个懂得 异步任务 , 定时任务 , 周期任务 的芹菜
  4. 删除binlog mysql_mysql中删除binlog的方法?mysql中如何删除binlog?
  5. HTTPS加密越来越流行,为何要加密?
  6. 在MATLAB function中可变的变量数据类型
  7. 15_torch.sigmoid,torch.nn.Sigmoid之间的区别
  8. YOLO V1,V2, V3的记录
  9. nopcommerce笔记3 还可以控制什么
  10. 渐近记号(Asymptotic Notations)
  11. 剑桥口语 — 48 个音标标准口型与细节发音
  12. python编程大赛队名_阿尔托莉雅队?编程大赛冠军队伍名字亮了
  13. 【马列GISer】第七届全国大学生GIS应用技能大赛上午A题参考答案(非考题)
  14. Andriod 第三方 ROM
  15. 前端设置画布的高度_前端页面内的高度、位置简述
  16. 养生粥秘方,据说可以补气、泻火和去湿
  17. three good things
  18. .net Application.DoEvents()
  19. PIL.image保存图片
  20. 深度分享|姚劲波:创业要趁早,要做未来的事情!

热门文章

  1. 计算机英语六级,英语六级作文范文:计算机
  2. Linux原始网络编程,Linux操作系统网络编程 原始套接字 (1)
  3. 基于 Docker 的微服务架构
  4. Fusion组件库是如何支持多语言能力的
  5. HTML5中本地储存概念是什么,什么优点 ,与cookie有什么区别?
  6. DEVEXPRESS---TREELIST的使用
  7. django 中静态文件项目加载问题
  8. CentOS忘记普通用户密码解决办法
  9. oracle的db link
  10. 北大青鸟组建与维护企业网络高级技术PPT课件