如题,看看,下面的代码不会异常,为什么?
class A {
private int m_test = 0;
private static B m_testb = (new A()).new B(); public static void main( String[] args){
m_testb.run();
System.out.println(" this is null");
}
class B{
public void run(){
m_testb = null;
System.out.println("I'm null");
print();
}
private void print(){
System.out.println( "I'm print");
}
}
}
class A {
private int m_test = 0;
private static B m_testb = (new A()).new B(); public static void main( String[] args){
m_testb.run();
System.out.println(" this is null");
}
class B{
public void run(){
m_testb = null;
System.out.println("I'm null");
print();
}
private void print(){
System.out.println( "I'm print");
}
}
}
解决方案 »
- SocketException的问题
- 帮忙看看这2句是啥意思!
- 通过SmartInvoke用java与flex轻松构建cs程序
- java反编译时出现brea goto JVm 的代码怎么处理 现在请求大哥们帮忙啊
- 如何在JTable单元格中加入一个JButton
- java.net.ConnectException: Connection refused
- 如何判断一个类是否继承自另一个类
- javax.naming.CommunicationException问题 请高手帮忙,小弟感激不尽
- java中类似memset的函数是什么?
- 如何用java实现word文档(含图片和表格等)转换成html文件
- 求一个完整代码,生成一个新的XML文件
- 请问各位大哥!!如何取出一副图每个像素的颜色,然后在去改变颜色,然后图片?我是菜中菜鸟。。。
请仔细看run方法。
而是对象没有人引用时才可能会被释放你在print();后 System.out.println(this); //this也是引用