是不是要自己写函数阿

解决方案 »

  1.   

    Test test;
    if (test == null ){
    ....................
    }
      

  2.   

    倒! 无语,建议你先看看Java的基础知识
      

  3.   

    是吗?
    java对象的名称是指向内存空间的吧?public class test{
    public int i; public static void main(String[] args) {
    test t = new test();
    if(t == null){
    System.out.println("null");

    }
    else
    {
    System.out.println("not null");
    }
    System.out.println("over");

    }
    }输出:
    not null
    over
      

  4.   

    test t = new test();
    -----------
    已经不是空了
      

  5.   

    像 test t;这样的对象声明 在java中是引用对象  所以可以用t=null 来判断 一个对象是不是空
      

  6.   

    test t;只是声明了一个空句柄,但并没有指向任何对象;
    test t= new test();new 了,就不一样了,已经创建了一个test实例;句柄t就指向这个实例
      

  7.   

    可以这样写,不过你要重载一下equals
    if(target==null || target.equals(new test())){
        //then target is an empty object
    }