解析中的数字的数据类型是什么

时间:2015-09-19 15:21:55

标签: android parse-platform

我从解析中检索数据时收到错误。 parse对象的类型号为

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double   

我正在使用ParseQuery来获取对象

for(ParseObject sample:ob){
        k= (double) sample.get("time");
        l= (double) sample.get("ppm");


        lineGraph(k,l);
    }

1 个答案:

答案 0 :(得分:0)

如果你想要一个双变量,那么这样做:

for(ParseObject sample:ob){
    k = sample.getDouble("time");
    l = sample.getDouble("ppm");


    lineGraph(k,l);
}

如果你想要一个int变量,那么这样做:

for(ParseObject sample:ob){
    int k = sample.getInt("time");
    int l = sample.getInt("ppm");


    lineGraph(k,l);
}