Proxy基础---------获取collection接口的构造跟方法
1----查看proxy api

2------测试代码
package cn.proxy01;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Collection;
public class Proxy {
public static void main(String[] args) {
Class clazzProxy = java.lang.reflect.Proxy.getProxyClass(Proxy.class.getClassLoader(), Collection.class);
System.err.println("代理名称:"+clazzProxy.getName());
System.err.println("--------通过代理获取collection的构造 ---------------");
//$Proxy0()
//$Proxy(参数名,参数类型)
Constructor[] constructors = clazzProxy.getConstructors();
for(Constructor constructor : constructors){
String constructionName = constructor.getName();
StringBuilder builder = new StringBuilder(constructionName);
builder.append("(");
Class[] parameters = constructor.getParameterTypes();
for(Class params : parameters){
String param = params.getName();
builder.append(param+",");
}
if(parameters.length != 0 || parameters != null){
builder.deleteCharAt(builder.length()-1);
}
builder.append(")");
System.err.println(builder.toString());
}
System.err.println("--------通过代理获取collection的方法 ---------------");
//remove(java.lang.Object)
Method[] methods = clazzProxy.getMethods();
for(Method method : methods){
String methodName = method.getName();
StringBuilder builder = new StringBuilder(methodName);
builder.append("(");
Class[] parameters = method.getParameterTypes();
for(Class params : parameters){
String param = params.getName();
builder.append(param+",");
}
if(parameters.length != 0 || parameters != null){
builder.deleteCharAt(builder.length()-1);
}
builder.append(")");
System.err.println(builder.toString());
}
}
}
3----运行结果

Proxy基础---------获取collection接口的构造跟方法的更多相关文章
- Java容器---Collection接口中的共有方法
1.Collection 接口 (1)Collection的超级接口是Iterable (2)Collection常用的子对象有:Map.List.Set.Queue. 右图中实现黑框的ArrayLi ...
- List接口相对于Collection接口的特有遍历方法
package com.hxl; import java.util.ArrayList; import java.util.List; public class Test { public stati ...
- Java基础(二十)集合(2)Collection接口
1.Collection接口通常不被直接使用.但是Collection接口定义了一些通用的方法,通过这些方法可以实现对集合的基本操作,因为List接口和Set接口都实现了Collection接口,所以 ...
- 16、Collection接口及其子接口Set和List(常用类LinkedList,ArrayList,Vector和Stack)
16.Collection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements).一些Collection允许相同 ...
- JAVA中Collection接口和Map接口的主要实现类
Collection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements).一些Collection允许相同的元素 ...
- JAVA笔记17-容器之一 图、Collection接口、Iterator接口(重要)
掌握1136: (1)1个图 (2)1个类:Collections (3)3个知识点:For(了解),Generic泛型,Auto-boxing/unboxing(自动打包/解包) (4)6个接口:C ...
- Collection接口中的方法的使用
add(Object e):将元素e添加到集合coll中size():获取添加的元素的个数addAll(Collection coll1):将coll1集合中的元素添加到当前的集合中clear():清 ...
- Collection接口
Collection接口所定义的方法: clear:清空 retainAll 求一个Collection和另一个 Collection的交集. object[] toArray() 把里面的各个对象 ...
- Java中的集合(二)单列集合顶层接口------Collection接口
Java中的集合(二)单列集合顶层接口------Collection接口 Collection是一个高度封装的集合接口,继承自Iterable接口,它提供了所有集合要实现的默认方法.由于Iterab ...
随机推荐
- January 18th, 2018 Week 03rd Thursday
To strive, to seek, to find, and not to yield. 去奋斗,去寻觅,去探索,但绝不屈服. Strive for our dreams, seek the ve ...
- Java7/8 中 HashMap 和 ConcurrentHashMap的对比和分析
大家可能平时用HashMap比较多,相对于ConcurrentHashMap 来说并不是很熟悉.ConcurrentHashMap 是 JDK 1.5 添加的新集合,用来保证线程安全性,提升 Map ...
- python六十一课——高阶函数之reduce
2).reduce(fn,lsd): 参数一:fn --> 函数对象 参数二:lsd --> 序列对象 功能: 先将lsd中的第一和第二个元素去除传入到fn中参与运算, 运算后得到结果,再 ...
- R环境搭建
R下载安装 https://mirrors.tuna.tsinghua.edu.cn/CRAN/ RStudio下载安装 https://www.rstudio.com/products/rstudi ...
- UVa 11846 - Finding Seats Again
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- input框下拉综合搜索
静态页面 <form action="houtai.php" method="get"> ...
- B+ Tree vs B Trees
原文地址:https://blog.csdn.net/dashuniuniu/article/details/51072795 引子 最近一直回顾自己曾经写的一些文档,有一篇是关于 Clang Rew ...
- leetcode538. Convert BST to Greater Tree
https://www.cnblogs.com/grandyang/p/6591526.html 这个题本质上是中序遍历的反向.中序遍历是从小到大,而这个题目是从大到小,然后每个数加上比自己大的所有数 ...
- Mac下安装Mongodb
Mac下安装Mongodb 一: 安装MongoDB: Mac下安装MongoDB有两种方法,第一种是通过源码安装,另一种是使用 homebrew, 下面我使用homebrew来安装,首先我们需要安装 ...
- Objective-C 禁用NSMenu中的系统services菜单项
当用NSMenu创建一个右键菜单时,mac系统会默认插入一些服务(services)菜单项,如下图,xlsx文件的右键菜单中,除了自定义的菜单项:“转发”和“收藏”等等,还有“在 Finder中显示简 ...