阅读背景:

如何将每个枚举值作为字符串列表?

来源:互联网 
public enum CountryDefaultAddressEnum {
    // Country or Region , Contact Name, Street Address, City, State, ZIP Code
    US_CAL("US", "CA Address", "2065 Hamilton Avenue", " ", "San Jose", "CA",
            "95125"),
    US_SJ("US", "CA Address", "201 South Fourth Street", " ", "San Jose", "CA",
            "95112");

    private CountryDefaultAddressEnum(String countryOrRegion,
            String contactName, String streetAddress, String streetAddress2,
            String city, String state, String zipCode) {
        this.countryOrRegion = countryOrRegion;
        this.contactName = contactName;
        this.streetAddress = streetAddress;
        this.streetAddress2 = streetAddress2;
        this.city = city;
        this.state = state;
        this.zipCode = zipCode;
    }

public String getValue() {
    return String.format("%s %s %s %s %s %s %s", countryOrRegion, contactName, streetAddress, streetAddress2, city, state, zipCode);
    }
}

public static void main(String args[]) {
    for(CountryDefaultAddressEnum countryAddr : US_CAL.values()) {
      System.out.println(countryAddr + ": " + countryAddr.getValue());
    }
}
public enum CountryDefaultAddressEnum {
    // 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: