【发布时间】:2014-04-26 20:54:52
【问题描述】:
我看到了一些关于同一件事的其他问题,但其中任何一个都解决了我的问题。可能是因为我不明白它的概念。
我有两个List<String>:
List<String> PlatformInfo1 = new ArrayList
List<String> PlatformInfo2 = new ArrayList
那些列表内容来自我的数据库的一些信息:
PlatformInfo1= [{"Nnodes":"163"}]
PlatformInfo2= [{"Commnet":"Windows Machine"}]
为了与每个元素交互,我尝试将两个数组都包含在一个对象 List<String> 中:
List<String> PlatformInfoGI = new ArrayList<String>();
PlatformInfoGI.addAll(PlatformInfo1);
PlatformInfoGI.addAll(PlatformInfo2);
我得到的结果是:
Value of PlatformInfoGI: [{"Nnodes":"163"},{"Commnet":"Windows Machine"}]
可以做一些事情将那些List<String> 变成类似的东西:
Value of PlatformInfoGI: [{"Nnodes":"163","Commnet":"Windows Machine"}]
NOTE 元素之间缺少大括号。
我想要的是一个List<String>,它只有一个元素和不同的属性(字符串)
【问题讨论】:
-
一个包含一个元素和该元素不同属性的列表,听起来您需要创建一个自定义对象列表或两个字符串的映射。
-
这段代码无法编译。
标签: java string arraylist merge