里面的元素如果不這么寫(xiě),還可以怎么寫(xiě)?
car?[?]?carForRent={new?passengerCar(1,"奧迪A4",500,4),
new?passengerCar(2,"馬自達(dá)6",400,4),
new?pickUp(3,"皮卡雪6",450,4,2),
new?passengerCar(4,"?金龍?",800,20),
?new?trunk(5,"松花江",400,4),
new?trunk(6,"依維柯",1000,20)};
比如?new?trunk(6,"依維柯",1000,20)如果不直接在這里寫(xiě),在子類(lèi)里寫(xiě)?怎么寫(xiě)?括號(hào)里的6,"依維柯",1000,20是對(duì)象的屬性?
2017-05-19
比如寫(xiě)成
passengerCar a1=new?passengerCar(1,"奧迪A4",500,4);
passengerCar a2=new?passengerCar(2,"馬自達(dá)6",400,4);
pickUp b1=new?pickUp(3,"皮卡雪6",450,4,2);
passengerCar a3=new?passengerCar(4,"?金龍?",800,20);
trunk c1=new?trunk(5,"松花江",400,4);
trunk c2=new?trunk(6,"依維柯",1000,20);
Car?carForRent[]=[a1,a2,b1,a3,c1,c2];
這么寫(xiě)對(duì)不對(duì)?
2017-05-18
太深?yuàn)W,回答不起