1.由字符串引起的空指针异常:
错误示例:初始化一个字符串:String comType = “”;
解决办法:抛出空指针异常:
try {
if (componentList.size()!=0){
comType = componentList.get(0).getComponentType();
}
}catch (NullPointerException e){
System.out.println(“字符串空指针错误!”);
}
1.由字符串引起的空指针异常:
错误示例:初始化一个字符串:String comType = “”;
解决办法:抛出空指针异常:
try {
if (componentList.size()!=0){
comType = componentList.get(0).getComponentType();
}
}catch (NullPointerException e){
System.out.println(“字符串空指针错误!”);
}