java新建居民档案
时间: 2023-11-25 09:51:31 浏览: 55
以下是Java新建居民档案的示例代码:
```java
import java.util.HashMap;
import java.util.Map;
public class Resident {
private String name;
private int age;
private String gender;
private String address;
private String phone;
public Resident(String name, int age, String gender, String address, String phone) {
this.name = name;
this.age = age;
this.gender = gender;
this.address = address;
this.phone = phone;
}
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("age", age);
map.put("gender", gender);
map.put("address", address);
map.put("phone", phone);
return map;
}
}
// 创建居民档案
Resident resident = new Resident("张三", 30, "男", "北京市朝阳区", "13888888888");
Map<String, Object> residentMap = resident.toMap();
```
阅读全文