---------------------- ASP.Net+Unity开发、.Net培训、期待与您交流! ----------------------
Method类
//反射综合案例
Collection collections = new ArrayList();//打印为4
//Collection collections = new HashSet();//打印为3
//HashSet在存放对象时会判断是否相同
//hashCode的存放是按区域存放的,在查找是否有相同元素时是按区域寻找
ReflectPoint pt1 = new ReflectPoint(3,3);
ReflectPoint pt2 = new ReflectPoint(3,4);
ReflectPoint pt3 = new ReflectPoint(3,5);
collections.add(pt1);
collections.add(pt2);
collections.add(pt3);
collections.add(pt1);
pt1.y = 7;//赋值后pt1在内存中更改了区域
collections.remove(pt1);//因为区域更改了,所以搜寻不到,内存溢出
System.out.println(collections.size());
//框架的搭建(通过配置文件与反射创建ArrayList)
//配置文件
className=java.util.ArrayList//配置文件在Properties中
InputStream ips = new FileInpuStream("config.properties");//配置关联文件
Properties props = new Properties();
props.load(ips);
ips.close();
String className = props.getProperties("className");
Collection collections = (Collection)Class.forName(className).newInstance();