question for write
来源:互联网 发布:淘宝信用卡套现方法 编辑:程序博客网 时间:2024/06/16 16:42
Object类有什么方法呢?
1. getClass() 2. hashCode() 3. equals() 4. toString() 5. clone() 6. wait() 7. notify() 8. notifyAll() 9. finalize()
内存泄漏的例子:
Vector v = new Vector(10);for (int i = 1; i<100; i++){Object o = new Object();v.add(o);o = null;}什么是内存泄漏啊?就是这个对象你不用了,但是GC不会对他进行回收。这才是内存泄漏。上面100个obj无用了。但是Vector中有他的引用。所以GC不会回收。造成内存泄漏。
public static void main(String[] args){ Set<Student> set = new HashSet<Student>(); Student s1 = new Student("Jack"); Student s2 = new Student("Mary"); Student s3 = new Student("Eason"); set.add(s1); set.add(s2); set.add(s3); System.out.println(set.size());//3 s2.setName("Jackson"); //修改属性,此时s2元素对应的hashcode值发生改变 set.remove(s2); // remove不掉,造成内存泄漏 set.add(s2); // 添加成功 System.out.println(set.size());//4
}
答案是:22,34,17
super5,执行构造函数的时候的this表示是谁的对象呢?其实是如果执行构造函数体的时候,对象已经new出来了。构造方法没执行完,对象也已经new出来了。this表示。所以你看super(5)中的this表示的是B子类的对象。所以执行B类的setValue方法。
在getValue中,如果在try{}中返回的值,在finally中给你改了。那么返回的是更改前的值。
public A (int v){
setValue(v)
}
这里面的setVaule方法,其实前面有一个this。this表示谁呢?表示方法的调用者对象。是B类的对象。
0 0
- question for write
- nfs for Android question
- Question about applying for colleges?
- Question for KVM VGA-Passthrough
- Question for Python Class 3
- Hierarchical Question-Image Co-Attention for Visual Question Answering
- Hierarchical Question-Image Co-Attention for Visual Question Answering
- write for these days
- Write Tests for People
- Write Tests for People
- HDOJ 5329 Question for the Leader
- hdu 5329 Question for the Leader
- hdu 5329 Question for the Leader
- Stacked Attention Networks for Image Question Answering
- Dynamic Coattention Networks For Question Answering
- question
- question
- question
- Unity3D中的线性插值Lerp()函数解析
- 17 猴子吃桃
- Linux线程编程 - 线程同步机制之条件变量
- 错误和异常处理
- Golang1.7闲来无事写了一个基于Gob的tcp通讯用的包
- question for write
- Reveal使用教程
- dijkstra(n^2)求某个点到所有点的最短路径
- C++ STL初识
- textView 中英文混排导致的自动换行出现的混乱的解决方案
- mfc图片自适应picture control
- JasperReport
- Mbox沙箱
- APP使用自己的静态库,但在打包时出现的问题解决