2个回答
展开全部
没注意,你要输出x对象的值啊你重写的是ACAR的toString()输出时用System.out.println(a[i].xToString());加个 xToString 方法好了 abstract class ACar { int ModelsNum; // 车型编号 String Carname; // 车型名称 int NumberOfPeople; // 载客量 int load; // 载重量 int price; // 每天单价 int money; // 支付总金额 // String[] x = {Carname}; Object[] x = { ModelsNum, Carname, NumberOfPeople, load, price }; public ACar(int new_ModelsNum, String new_Carname, int new_NumberofPeople, int new_load) { this.ModelsNum = new_ModelsNum; this.Carname = new_Carname; this.NumberOfPeople = new_NumberofPeople; this.load = new_load; } public abstract void run(); public String xToString() { return Arrays.toString(x); } @Override public String toString() { return "ACar [ModelsNum=" + ModelsNum + ", Carname=" + Carname + ", NumberOfPeople=" + NumberOfPeople + ", load=" + load + ", price=" + price + ", money=" + money + ", x=" + Arrays.toString(x) + "]"; }}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询