Java类类getComponentType()方法与示例
类类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()方法与示例相关推荐
- java.util.zip 用法,Java压缩文件工具类ZipUtil使用方法代码示例
本文实例通过Java的Zip输入输出流实现压缩和解压文件,前一部分代码实现获取文件路径,压缩文件名的更改等,具体如下: package com.utility.zip; import java.io. ...
- java散列法的运用实例,Java HashMap compute() 使用方法及示例
Java HashMap compute() 使用方法及示例 Java HashMap compute()方法计算一个新值,并将其与哈希映射中的指定键相关联. compute()方法的语法为: has ...
- math的用法在java中的使用,Java Math cbrt() 使用方法及示例
Java Math cbrt() 使用方法及示例 Java Math cbrt()方法返回指定数字的立方根. cbrt()方法的语法为: Math.cbrt(double num) 注意:cbrt() ...
- java arraylist 方法返回值,Java ArrayList get() 使用方法及示例
Java ArrayList get() 使用方法及示例 Java ArrayList get()方法返回指定位置存在的元素. get()方法的语法为: arraylist.get(int index ...
- java kryo_Kryo框架使用方法代码示例
Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...
- java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例
import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...
- java invalidate_Java Component.invalidate方法代码示例
import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...
- java hasmoreelements_Java IOException.hasMoreElements方法代码示例
import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...
- java singletonlist_Java Collections singletonList()方法及示例
集合类singletonList()方法 (Collections Class singletonList() method) singletonList() method is available ...
- Java Math toIntExact() 使用方法及示例 long转int
Java Math toIntExact()方法从指定的long参数返回int值. toIntExact()方法的语法为: Math.toIntExact(long value) 注意:toIntEx ...
最新文章
- 黑盒测试之等价类测试
- Andrew Gelman、Aki Vehtari​ | 过去50年最重要的统计学思想是什么?
- Celery - 一个懂得 异步任务 , 定时任务 , 周期任务 的芹菜
- 删除binlog mysql_mysql中删除binlog的方法?mysql中如何删除binlog?
- HTTPS加密越来越流行,为何要加密?
- 在MATLAB function中可变的变量数据类型
- 15_torch.sigmoid,torch.nn.Sigmoid之间的区别
- YOLO V1,V2, V3的记录
- nopcommerce笔记3 还可以控制什么
- 渐近记号(Asymptotic Notations)
- 剑桥口语 — 48 个音标标准口型与细节发音
- python编程大赛队名_阿尔托莉雅队?编程大赛冠军队伍名字亮了
- 【马列GISer】第七届全国大学生GIS应用技能大赛上午A题参考答案(非考题)
- Andriod 第三方 ROM
- 前端设置画布的高度_前端页面内的高度、位置简述
- 养生粥秘方,据说可以补气、泻火和去湿
- three good things
- .net Application.DoEvents()
- PIL.image保存图片
- 深度分享|姚劲波:创业要趁早,要做未来的事情!