ava.lang.Class.getDeclaredMethod()方法
来源:互联网 发布:占星骰子在线软件 编辑:程序博客网 时间:2024/06/10 23:08
java.lang.Class.getDeclaredMethod()方法
java.lang.Class.getDeclaredMethod()方法用法实例教程 - 方法返回一个Method对象,它反映此Class对象所表示的类或接口的指定已声明方法。
<iframe id="iframeu1064372_0" src="http://pos.baidu.com/dchm?rdid=1064372&dc=2&di=u1064372&dri=0&dis=0&dai=1&ps=325x409&dcb=BAIDU_SSP_define&dtm=BAIDU_DUP_SETJSONADSLOT&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1463996464998&ti=java.lang.Class.getDeclaredMethod()%E6%96%B9%E6%B3%95&ari=1&dbv=2&drs=1&pcs=1305x604&pss=1305x1464&cfv=0&cpl=4&chi=1&cce=true&cec=UTF-8&tlm=1463996464&ltu=http%3A%2F%2Fwww.yiibai.com%2Fjavalang%2Fclass_getdeclaredmethod.html&ltr=https%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Djk0O5do5u_s4m3ABGo99XO7NBe4HIvqKSZRSKarsxVp3QSwBhn14kksECRIiYzO7gi0mXSmkLQwXHYbm6knxbSUBs4W39rKAqk4b1kjRxga%26wd%3D%26eqid%3Db46f7266000063d3000000055742cfec&ecd=1&psr=1366x768&par=1366x728&pis=-1x-1&ccd=24&cja=false&cmi=6&col=zh-CN&cdo=-1&tcn=1463996465&qn=201a2dc1319f1ce9&tt=1463996464979.26.165.169" width="728" height="90" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="box-sizing: border-box; border-width: 0px; border-style: initial; vertical-align: bottom; margin: 0px;"></iframe>
描述
java.lang.Class.getDeclaredMethod()方法返回一个Method对象,它反映此Class对象所表示的类或接口的指定已声明方法。name参数是一个字符串,指定所需的方法的简单名称,parameterTypes参数是一个数组的Class对象识别方法的形参类型,在声明的顺序
声明
以下是java.lang.Class.getDeclaredMethod()方法的声明
public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException
参数
name -- 方法的名称
parameterTypes -- 参数数组
返回值
匹配指定名称和参数的类的方法,此方法返回的Method对象
异常
NoSuchMethodException -- 如果匹配方法未找到
NullPointerException -- 如果name 为 null.
SecurityException -- If a security manager, s, is present.
实例
下面的例子说明了如何使用java.lang.Class.getDeclaredMethod()方法
package com.yiibai;import java.lang.reflect.*;public class ClassDemo { public static void main(String[] args) { ClassDemo cls = new ClassDemo(); Class c = cls.getClass(); try { // parameter type is null Method m = c.getDeclaredMethod("show", null); System.out.println("method = " + m.toString()); // method Integer Class[] cArg = new Class[1]; cArg[0] = Integer.class; Method lMethod = c.getDeclaredMethod("showInteger", cArg); System.out.println("method = " + lMethod.toString()); } catch(NoSuchMethodException e) { System.out.println(e.toString()); } } private Integer show() { return 1; } public void showInteger(Integer i) { this.i = i; } public int i = 78655;}
让我们来编译和运行上面的程序,这将产生以下结果:
method = private java.lang.Integer ClassDemo.show()method = public void ClassDemo.showInteger(java.lang.Integer
0 0
- ava.lang.Class.getDeclaredMethod()方法
- java.lang.Class.getDeclaredMethod()方法
- java.lang.Class.getDeclaredMethod()方法
- java.lang.Class.getDeclaredMethod()方法详解
- Java.lang.Class.getDeclaredMethod()方法用法
- 反射机制 Class.getDeclaredMethod
- Tomcat ava.lang.UnsupportedClassVersionError: Bad version number in .class file
- Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack ava
- ava.lang.IllegalAccessException
- 关于getDeclaredMethod方法的用法
- java_class.getMethod 与 class.getDeclaredMethod的区别
- java_class.getMethod 与 class.getDeclaredMethod的区别
- ava.lang.VerifyError: class akka.remote.WireFormats$AkkaControlMessage overrides final method getUnk
- java.lang.Class.getDeclaredField()方法
- java.lang.Class.getComponentType()方法
- java.lang.Class.getMethod()方法
- java.lang.Class.isPrimitive()方法
- getDeclaredMethod方法和getMethod方法区别?
- 高德地图不响应点击事件
- 李龙网谈大学生和残疾人如何做好电商服务平台(节选)
- VRP系统-2
- 北航复试上机14真题
- Android添加快捷方式(Shortcut)到手机桌面
- ava.lang.Class.getDeclaredMethod()方法
- anr日志
- 自定义View实例(一)----微博运动积分的实现
- 趟过Appium的坑
- visudo控制用户对系统的使用权限
- 利用SurfaceView来实现android本地视频播放
- Appium Python API
- 支持多版本接口api的开源框架NHVersion
- iOS 8 Auto Layout界面自动布局系列3-使用代码添加布局约束
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
喊麦培训
喊麦软件
酒吧喊麦
dj喊麦现场
ktv喊麦
喊麦dj舞曲
dj现场喊麦
喊麦开场词
喊麦另类
流行喊麦
原创喊麦
喊麦dj歌曲
喊麦的歌曲
天佑喊麦歌曲大全
喊麦大全100首
喊麦歌曲大全
喊麦歌词大全100首
喊麦歌曲大全100首
小仙儿dj喊麦歌曲大全
喊麦开场白台词霸气
新手喊麦一般先学什么
喊麦歌词大全
喊麦是什么意思
好听的喊麦歌曲排行榜
喊麦声卡多少钱
yy喊麦歌曲排行榜
天佑喊麦大全
另类喊麦歌词
喊麦歌词霸气一点的
喊麦的歌曲有哪些
喊麦什么意思
天佑喊麦的歌
喊麦好听的歌
很火的喊麦歌曲
三轮车歌曲喊麦
喊麦歌曲排行榜
手机喊麦软件
经典喊麦歌曲
另类喊麦歌曲大全
好听的喊麦歌曲
yy喊麦歌曲大全