java - 如何在内部类中使用枚举?
问题描述
我有一个 PhoneContact 类,它是一个内部类,我需要为电话接线员定义一个枚举。当我尝试在 PhoneContact 类中定义它时,出现错误。这样做的正确方法是什么?代码:
public class Contacts {
class Contact {
private String date;
private String type;
public Contact(String date, String type) {
LocalDate ld = LocalDate.now();
String fd = ld.toString();
this.date = fd;
this.type = type;
}
public boolean isNewerThan(Contact c) {
if(this.date.compareTo(c.date) <= 0) {
return true;
} else {
return false;
}
}
public String getType() {
return type;
}
}
class PhoneContact extends Contact {
private String phone;
public PhoneContact(String date, String type, String phone) {
super(date, type);
this.phone = phone;
}
public String getPhone() {
return phone;
}
}
public static void main(String[] args) {
}
}
解决方案
推荐阅读
- python - 如何从具有帐户密钥的api获取请求
- java - JasperSoft 报告未在 java jar 文件中运行
- mysql - 如何使用 SQL 加入 postmeta 表并获取自定义字段日期之前的帖子
- azure - 我想使用 Azure 数据工厂从谷歌仪表板获取数据
- android - 如何以编程方式查找安装在 Android 手机中的社交共享应用程序列表?
- javascript - 如何匹配在字符串末尾终止的子字符串?
- spring - 如果消息失败并由 AfterRollbackProcessor 处理,如何在 Spring Kafka 中提交偏移量
- asp.net-mvc - .net core中DICOM图像的数据解析和发送
- google-app-engine - 具有独立 FE 和 BE 服务的 Google Cloud
- ios - 发送 Http Post 请求在 IoS 中返回 500 状态码