呵呵,补贴代码的一般出错误是这样的class Sample{ JLable jLable;// here is wrong JLable jLable = new jLable is right public Sample(){ hehe } public void myMethod(){ jLable.setText( "you wrong" ); } }
呀,又少打括号了,郁闷。 class Sample{ JLable jLable;// here is wrong JLable jLable = new jLable() is right public Sample(){ hehe } public void myMethod(){ jLable.setText( "you wrong" ); } }
JLable jLable;// here is wrong JLable jLable = new jLable is right
public Sample(){
hehe
}
public void myMethod(){
jLable.setText( "you wrong" );
}
}
class Sample{
JLable jLable;// here is wrong JLable jLable = new jLable() is right
public Sample(){
hehe
}
public void myMethod(){
jLable.setText( "you wrong" );
}
}
Vector vec=new Vector();
method(Stirng str){
vec.put(sre);
}
main(){
String str=null;
method(str); //throw new NullPointerException();这里会抛出异常
}