我在使用ArrayList
of 时遇到以下问题ArrayList
。我做下一个:
Hashtable<SensorType, ArrayList<Float>> hash = new Hashtable<SensorType, ArrayList<Float>>();
int numKeys = sensors.size();
ArrayList<ArrayList<Float>> arrays = new ArrayList<ArrayList<Float>>(numKeys);
for(int i = 0; i < arrays.size(); i++){
ArrayList<Float> aux = new ArrayList<Float>();
arrays.add(aux);
}
String columns = getColumnsName(sensors);
String sql = "select " + columns + " from " + nameTable + " where " + ID + " BETWEEN " +
start + " AND " + end + ";";
Cursor c = db.rawQuery(sql, null);
c.moveToFirst();
while(!c.isAfterLast()){
for(int i = 0; i < numKeys; i++)
arrays.get(i).add(c.getFloat(i));
c.moveToNext();
}
这总是给我一个ArrayOutOfBoundsException
. 它告诉每个数组(内部)的大小为 0。我做错了什么?