NumberFormat异常无效int:" [1,2,3,4,5,6,7,8,9,10]"数组列表

时间:2015-06-05 07:05:35

标签: java android arraylist

有谁能告诉我如何从ArrayList获取int值?

try {

    getitemno = Integer.parseInt(arr.get(index));

    getid =  getitemno;
    new AllRoutesDetails().execute();
    Log.d("id", String.valueOf(getid));
}
catch (NumberFormatException e) {
    e.printStackTrace();
}

阵列数据

"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]"

2 个答案:

答案 0 :(得分:0)

ArrayList<Integer> arr = new ArrayList<Integer>();
int resultedValue = arr.get(index);

答案 1 :(得分:0)

您可以创建不需要类型转换的Integer ArrayList:

 ArrayList<Integer> al=new ArrayList<Integer>();
    for(int i=1;i<11;i++)
    al.add(i);

获取值只需使用

let position be=0;
int id=al.get(position); or al.get(0);