是一种常见的需求,可以通过以下几种方式来实现:
public class User {
private String[] addresses;
// getter and setter methods
}
public class User {
private List<String> addresses;
// getter and setter methods
}
public class User {
private List<Address> addresses;
// getter and setter methods
public static class Address {
private String street;
private String city;
private String state;
private String country;
// getter and setter methods
}
}
以上是三种常见的在实体类中存储多个地址字段的方式。具体选择哪种方式取决于实际需求和业务场景。
腾讯云相关产品推荐:
领取专属 10元无门槛券
手把手带您无忧上云