public class Summary {
public static void main(String[] args){
Double[] flowData = new Double[100];
flowData[0] = 325.1;
double sum = 0;
for (int i = 0; i <100 ; i++) {
sum =sum + flowData[i];
}
System.out.println("您今天收入总金额为:"+sum+"元");
}
报错:
Exception in thread "main" java.lang.NullPointerException
at day05.Summary.main(Summary.java:10)
double类型数组下,默认值不是0.0吗?最多加0啊?怎么会报错空指针异常啊? |
|