【发布时间】:2012-05-29 05:18:05
【问题描述】:
解析我的文件“s”后包含AttributeGet:1,16,10106,10111
所以我需要获取attributeIDGet List中冒号后的所有数字。我知道有几种方法可以做到这一点。但是有什么方法可以直接将List<String> 转换为List<Integer>。
由于下面的代码抱怨类型不匹配,所以我尝试执行 Integer.parseInt,但我想这不适用于 List。这里 s 是字符串。
private static List<Integer> attributeIDGet = new ArrayList<Integer>();
if(s.contains("AttributeGet:")) {
attributeIDGet = Arrays.asList(s.split(":")[1].split(","));
}
【问题讨论】:
标签: java list collections arraylist