【发布时间】:2021-10-09 10:54:50
【问题描述】:
我希望以下方法返回 String 类型的 List 而不是 String 返回类型,调用后续“build”的另一个方法将接收 String 类型的 List(不是 StringBuilder)
public String build(String Uri, String Id) {
StringBuilder DocUri = new StringBuilder();
if (Uri.contains("newString")) {
DocUri.append("user-profile1/users/").append(Id).append("/user.xml");
DocUri.append("user-profile2/users/").append(Id).append("/user.xml");
DocUri.append("user-profile3/users/").append(Id).append("/user.xml");
}
return DocUri.toString();
}
输出应该是: 其中 '1' 是传递给上述方法的 ID
[user-profile1/users/1/user.xml, user-profile2/users/1/user.xml, user-profile3/users/1/user-profile.xml]
【问题讨论】: