解析我的文件S包含后 AttributeGet:1,16,10106,10111
所以我需要在attributeIDGet列表分号后能得到所有的数字。我知道有几个方法可以做到这一点。但有什么办法,我们可以通过直接将列表<弦乐> 到列表<整数方式> 由于低于code抱怨类型不匹配,所以我试图做的Integer.parseInt,但我想这不会对列表工作。下面就为String。
私有静态列表<整数GT; attributeIDGet =新的ArrayList<整数GT;();;如果(s.contains(AttributeGet:)){ attributeIDGet = Arrays.asList(s.split(:)[1] .split(,));}解决方案
没有,你需要循环阵列上
的(一个String:strList)intList.add(Integer.valueOf(S));After parsing my file s contains AttributeGet:1,16,10106,10111
So I need to get all the numbers after semi colon in the attributeIDGet List. I know there are several ways to do it. But is there any way we can Directly convert List<String> to List<Integer>. As the below code complains about Type mismatch, so I tried to do the Integer.parseInt, but I guess this will not work for List. Here s is String.
private static List<Integer> attributeIDGet = new ArrayList<Integer>();; if(s.contains("AttributeGet:")) { attributeIDGet = Arrays.asList(s.split(":")[1].split(",")); }解决方案
No, you need to loop over the array
for(String s : strList) intList.add(Integer.valueOf(s));
更多推荐
转换列表&LT;串GT;列出&LT;整数GT;直
发布评论