• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
 






Nothing Is Impossible

 
 

Powered by 博客园
| 首页 | 新随笔 | | 订阅 订阅 | 管理

2012年1月16日

[Java反射机制] 通过反射机制创建类的实例并调用其方法
摘要: //通过“反射机制” 创建类的实例public class ReflectionDemo02 { public int add(int a, int b) { return a + b; } public static void main(String[] args) throws Exception { // TODO Auto-generated method stub // 反射第一步:获取要操作类的Class对象 // 获取Class对象的第二种方法、通过.class Class<?> classT... 阅读全文
posted @ 2012-01-16 19:18 forDream 阅读(3309) 评论(0) 推荐(0)
 
[Java反射机制] 运行期间获取任意类的所有方法声明
摘要: 关于反射机制的定义案例无意义、仅仅演示反射机制的初步印象import java.lang.reflect.Method;public class ReflectionDemo01 { public static void main(String[] args) throws Exception { Class<?> classType = Class.forName("java.lang.Integer"); Method[] methods = classType.getDeclaredMethods(); for (Method method... 阅读全文
posted @ 2012-01-16 18:58 forDream 阅读(631) 评论(0) 推荐(0)