亚咪吧 关注:15贴子:538
  • 2回复贴,共1

及时关闭流

只看楼主收藏回复

关闭流没有关闭对象,而是释放流所用到的工具,比如管道啥的
InputStream ips=new InputStream("config.properties"):
Properties pros=new properties();
pros.load(ips);
ips.close;
......


IP属地:福建1楼2012-12-17 22:23回复
    HashCode方法导致的内存泄露:
    一个User类重写了equals 和hashcode的方法,and then
    User user1=new User("亚咪",15);
    User user2=new User("lili",12);
    User user3=new User("lili",12);
    Collection collection=new HashSet();
    collection.add(user1);
    collection.add(user2);
    collection.add(user3);
    user3.setAge(16);//这个操作会导致内存泄露
    collection.remove(user3);
    Sysout(collection.size);//2个


    IP属地:福建2楼2012-12-17 22:29
    回复
      getFields()获得某个类的所有的公共(public)的字段,包括父类。
      getDeclaredFields()获得某个类的所有申明的字段,即包括public、private和proteced,但是不包括父类的申明字段。


      IP属地:福建3楼2012-12-19 22:01
      回复