javaweb问题求解

packagelab1_1;  
importjava.beans.PropertyVetoException;  
importjava.beans.VetoableChangeListener;  
importjava.beans.VetoableChangeSupport;  
importjava.io.Serializable;  
publicclasslimitstudentimplementsSerializable{  
Stringname;  
intage;  
VetoableChangeSupportvcSupport;  
Stringuniversity;  
publiclimitstudent(){  
setName("tom");  
setAge(21);  
vcSupport=newVetoableChangeSupport(this);  
setUniversity("GZU");  
}  
publicvoid_tostring(){  
System.out.println("personalinformation:"+name+""+age+""+university);  
}  
publicStringgetName(){  
returnname;  
}  
publicvoidsetName(Strings){  
this.name=s;  
}  
publicvoidsetAge(inti){  
intold;  
old=age;  
try{  
vcSupport.fireVetoableChange("age",old,i);  
age=i;  
}catch(PropertyVetoExceptione){  
System.out.println(e);  
}  
}  
publicintgetAge(){  
returnage;  
}  
publicStringgetUniversity(){  
returnuniversity;  
}  
publicvoidsetUniversity(Strings1){  
this.university=s1;  
}  
publicvoidaddVetoableChangeListener(VetoableChangeListenervc1){  
vcSupport.addVetoableChangeListener(vc1);  
}  
publicvoidremoveVetoableChangeListener(VetoableChangeListenervc1){  
vcSupport.removeVetoableChangeListener(vc1);  
}  
}  
packagelab1_1;  
importjava.beans.PropertyChangeEvent;  
importjava.beans.PropertyVetoException;  
importjava.beans.VetoableChangeListener;  
publicclasstestlimitstudent{  
publictestlimitstudent(){}  
publicstaticvoidmain(String[]args){  
limitstudentst=newlimitstudent();  
System.out.println("初始信息:");  
st._tostring();  
st.addVetoableChangeListener(newVetoableChangeListener(){  
@Override  
publicvoidvetoableChange(PropertyChangeEvente)  
throwsPropertyVetoException{  
if(Integer.parseInt((e.getNewValue()).toString())<=20)  
throw(newPropertyVetoException("年龄太小"+e.getNewValue(),e));  
}  
});  
st.setAge(19);  
System.out.println("最后信息:");  
st._tostring();  
}  

}  

怎么破?
Exception in thread "Main Thread" java.lang.NullPointerException
    at lab1_1.limitstudent.setAge(limitstudent.java:34)
    at lab1_1.limitstudent.<init>(limitstudent.java:16)
    at lab1_1.testlimitstudent.main(testlimitstudent.java:11)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值