运行后提示Exception in thread "main" java.lang.NullPointerException.
Array应该是可以是任何类型的吧.感觉定义成一个class地类型应该没问题呀.
public class CustArray {
Customer [] custArray;
public CustArray() {
for (int j=0; j<custArray.length; j++){
custArray[j].arrivalTime=j;
custArray[j].length=2*j;
}
for (int j=0; j<custArray.length; j++)
System.out.println("custArray"+j+".arrival time: "+custArray[j].arrivalTime+".length: "+custArray[j].length);
}
public static void main(String[] args) {
new CustArray();
}
class Customer {
double arrivalTime;
double length;
double serviceTime;
}
}
Array应该是可以是任何类型的吧.感觉定义成一个class地类型应该没问题呀.
public class CustArray {
Customer [] custArray;
public CustArray() {
for (int j=0; j<custArray.length; j++){
custArray[j].arrivalTime=j;
custArray[j].length=2*j;
}
for (int j=0; j<custArray.length; j++)
System.out.println("custArray"+j+".arrival time: "+custArray[j].arrivalTime+".length: "+custArray[j].length);
}
public static void main(String[] args) {
new CustArray();
}
class Customer {
double arrivalTime;
double length;
double serviceTime;
}
}