你给一个为null的object进行操作.

解决方案 »

  1.   

    一般都是这样的情况 aObject.Method()  这里这个aObject  这里的aObject 就是导致这个NullPointerException的根源 (因为他是null)得
      

  2.   

    呵呵,补贴代码的一般出错误是这样的class Sample{
        JLable jLable;// here is wrong JLable jLable = new jLable is right
        public Sample(){
            hehe
        }
        public void myMethod(){
            jLable.setText( "you wrong" );
        }
    }
      

  3.   

    呀,又少打括号了,郁闷。
    class Sample{
        JLable jLable;// here is wrong JLable jLable = new jLable() is right
        public Sample(){
            hehe
        }
        public void myMethod(){
            jLable.setText( "you wrong" );
        }
    }
      

  4.   

    给你举个例子:
    Vector vec=new Vector();
    method(Stirng str){
      vec.put(sre);
    }
    main(){
    String str=null;
    method(str);      //throw new NullPointerException();这里会抛出异常
    }