可以运行,但是为什么说Systen.out.println((i+1)+"."+carsForRent[i].toString());出现异常?
public class Rent {
public static void main(String[] args)throws FileNotFoundException {
Car car = new Car();
Car[] carsForRent = {new Manned("奥迪A4",500,4),new Manned("马自达6",400,4),new MannedTruck("皮卡雪6",450,4,2),new Manned("金龙",800,20),new Truck("松花江",400,4),new Truck("依维柯",1000,20)};
System.out.println("欢迎使用答答租车系统:");
System.out.println("您是否要租车:1是 0否");
Scanner scan = new Scanner(System.in);
int input = scan.nextInt();
if(input == 1){
System.out.println("您可租车的类型及其价目表:");
System.out.println("序号 \t\t汽车名称 \t\t租金 \t\t容量\t");
for(int i=0;i<=carsForRent.length;i++){
System.out.println((i+1) +". " + carsForRent[i].toString());
}
}
}
}
}