0
請你幫我解決這個問題。陣列實例
問題: 考慮以下數組聲明
double readings[];
String urls[];
TicketMachine[] machines;
寫作業是完成以下任務:
- 使
readings
變量引用數組是能容納60個double
值 - 使
urls
變量引用一個數組,該數組能夠容納90個String
對象 - 使
machines
變量引用數組即能保五個TicketMachine
對象
我的回答:
//declare and instantiate object
double readings [] = new double [60];
String urls [] = new String [90];
TicketMachine machines [] = new TicketMachine [5];
我得到的錯誤是這樣的:
Main.java:16: readings is already defined in main(java.lang.String[])
double readings [] = new double [60];
^
Main.java:17: urls is already defined in main(java.lang.String[])
String urls [] = new String [90];
^
Main.java:18: machines is already defined in main(java.lang.String[])
TicketMachine machines [] = new TicketMachine [5];
謝謝各位的幫忙 – user228390 2009-12-31 21:56:59