- package cn.itcast.day1;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.util.Collection;
- import java.util.HashSet;
- import java.util.Properties;
- public class ReflectTest2 {
- public static void main(String[] args)throws Exception{
-
-
- InputStream ips = new FileInputStream("config.properties");
-
- Properties pro = new Properties();
-
- pro.load(ips);
- ips.close();
- String className = pro.getProperty("className");
-
- Collection collections = (Collection)Class.forName(className).newInstance();
-
-
- //Collection collections = new HashSet();
-
- ReflectPoint pt1 = new ReflectPoint(3,3);
- ReflectPoint pt2 = new ReflectPoint(5,5);
- ReflectPoint pt3 = new ReflectPoint(3,3);
-
- collections.add(pt1);
- collections.add(pt2);
- collections.add(pt3);
- collections.add(pt1);
-
- System.out.println(collections.size());
-
- }
- }
复制代码 张孝祥27天 里面的例子,一样的代码为什么结果不一样!!!
|
|