解析后我的文件"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(","));
}
Run Code Online (Sandbox Code Playgroud)