哪颗最亮的星星 发表于 2013-8-5 21:19
InputStream ips = new FileInputStream("config.properties");
Properties props = new Properties();
pr ...
还是错的呃。。。- import java.io.*;
- import java.util.*;
- import com.sun.xml.internal.fastinfoset.sax.Properties;
- public class ReflectTest2 {
- public static void main(String[] args) throws IOException{
- InputStream ips = new FileInputStream("config.properties");
- Properties props = new Properties();
- props.load(ips);
- ips.close();
- String className = props.getProperty("className");
- Collection collections =(Collection)Class.forName(className).newInstance();
-
- //Collection collections = new ArrayList();
- //Collection collections = new HashSet();
- ReflectionPoint pt1 = new ReflectionPoint(3,3);
- ReflectionPoint pt2 = new ReflectionPoint(5,5);
- ReflectionPoint pt3= new ReflectionPoint(3,3);
- collections.add(pt1);
- collections.add(pt2);
- collections.add(pt3);
- collections.add(pt1);
- pt1.y = 7; //改完后就取不走了 原来的数据找不着了 就叫做 内存泄露
- collections.remove(pt1);
- System.out.println(collections.size());
- }
-
- }
复制代码 |