Test类报错的原因是因为在不同的文件中定义了Landline和MobilePhone类,需要在Test类中引入这两个类的包才能使用。可以在Test类的开头加上以下代码:

import 包名.Landline; import 包名.MobilePhone;

其中“包名”是指Landline和MobilePhone类所在的包名,需要根据实际情况进行替换。例如,如果Landline和MobilePhone类都在同一个名为“phone”的包中,那么可以加上以下代码:

import phone.Landline; import phone.MobilePhone;

这样就可以解决Test类报错的问题了。

将Landline、MobilePhone和Test分别放在不同的文件中并且文件名与类名相同此操作之后Test类还是报错是为什么public class Landline private int balance; 余额 private int callFee; 通话费用分钟 public Landlineint balance int callFee thi

原文地址: https://www.cveoy.top/t/topic/hbSI 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录