【发布时间】:2022-01-10 01:31:13
【问题描述】:
我想更改列表中的值
实际输出: “概括”: [ { 值a:“1”, 标题计数:“20” } ]
必填项: “概括”: [ { 值 A:“1”, 标题计数:“20” } ]
需要通过在所需区域添加大写字母和空格来更改文本。
【问题讨论】:
-
分割文本和大写字母的标准是什么?此外,这似乎是列表中的地图。你能添加一些产生这个的Java代码吗?这将有助于帮助者。 :)
我想更改列表中的值
实际输出: “概括”: [ { 值a:“1”, 标题计数:“20” } ]
必填项: “概括”: [ { 值 A:“1”, 标题计数:“20” } ]
需要通过在所需区域添加大写字母和空格来更改文本。
【问题讨论】:
可能是这样的(假设 List 是字符串数组):
// Create List...
List<String[]> list = new ArrayList<>();
list.add(new String[] {"valuesa:\"1\"", "titlecount:\"10\""});
list.add(new String[] {"valuesb:\"2\"", "titlecount:\"20\""});
list.add(new String[] {"valuesc:\"3\"", "titlecount:\"30\""});
// Convert List...
for (String[] str : list) {
str[0] = str[0].toUpperCase().replace("VALUES", "Values ");
str[1] = str[1].replace("titlecount", "Title Count");
}
// Display List...
for (String[] str : list) {
System.out.println(Arrays.toString(str));
}
当运行到控制台窗口的输出将是:
[Values A:"1", Title Count:"10"]
[Values B:"2", Title Count:"20"]
[Values C:"3", Title Count:"30"]
【讨论】: