---------------------- ASP.Net+Android+IOS开发、.Net培训、期待与您交流! ----------------------
每一个.class文件我们在用的时候都要加载到内存里面来,那么它还是能加载一般的文件,但只能读取不能写入保存
public class HashSet_HashCold {
public static void main(String[] args) throws Exception{
//Collection set = new HashSet();
//类加载器相对路径,相对于当前类所在包下的
//InputStream in = HashSet_HashCold.class.getResourceAsStream("config.propertice");
//类加载器绝对路径
InputStream in = HashSet_HashCold.class.getResourceAsStream("/GaoXin/config.propertice");
Properties proper = new Properties();
proper.load(in);
String ClassName = proper.getProperty("ClassName");
in.close();
Collection set = (Collection) Class.forName(ClassName).getConstructor().newInstance();
ReflectPoint r1 = new ReflectPoint(3, 3);
ReflectPoint r2 = new ReflectPoint(4, 5);
ReflectPoint r3 = new ReflectPoint(3, 3);
ReflectPoint r4 = new ReflectPoint(7, 8);
set.add(r1);
set.add(r2);
set.add(r3);
set.add(r4);
set.add(r1); //存储同一个对象hashe值相等所以存不进去
//内存泄露问题
r1.y=8;
set.remove(r1);
System.out.println(set.size());
}
}
---------------------- ASP.Net+Android+IOS开发、.Net培训、期待与您交流! ----------------------