我不知道为什么Arraylist Stores存在类似的对象。 请帮助我。先感谢您。 我知道循环游标或存储在Arraylist中的逻辑存在一些问题。 数组列表以这种方式定义,
public ArrayList<Object> results=new ArrayList<Object>();
public ArrayList<String> arrTemp=new ArrayList<String>();
以下是我的代码:
db = getReadableDatabase();// /////--->Here database is opened
cursor = db.rawQuery("Select symbol,date,open,high,Low,close from testTBL;", null);
if (cursor.getCount() != 0) {
while (cursor.moveToNext()) {
arrTemp.clear();
arrTemp.add(cursor.getString(cursor.getColumnIndex("symbol")));
arrTemp.add(cursor.getString(cursor.getColumnIndex("date")));
arrTemp.add(cursor.getString(cursor.getColumnIndex("open")));
arrTemp.add(cursor.getString(cursor.getColumnIndex("high")));
arrTemp.add(cursor.getString(cursor.getColumnIndex("Low")));
arrTemp.add(cursor.getString(cursor.getColumnIndex("close")));
Log.v("arrayTemp inside while loop", ""+arrTemp);
results.add(arrTemp);
Log.v("Results stored", ""+results);
}
Log.v("Final Results", ""+results);
cursor.close();
}
db.close();
以下是Logcat输出:
03-03 02:35:38.614: V/arrayTemp inside while loop(337): [ACC, 25-Feb-13, 1,302.00, 1,321.00, 1,293.05, 1,305.60]
03-03 02:35:38.614: V/Results stored(337): [[ACC, 25-Feb-13, 1,302.00, 1,321.00, 1,293.05, 1,305.60]]
03-03 02:35:38.624: V/arrayTemp inside while loop(337): [ACC, 22-Feb-13, 1,300.05, 1,308.05, 1,295.00, 1,300.95]
03-03 02:35:38.624: V/Results stored(337): [[ACC, 22-Feb-13, 1,300.05, 1,308.05, 1,295.00, 1,300.95], [ACC, 22-Feb-13, 1,300.05, 1,308.05, 1,295.00, 1,300.95]]
03-03 02:35:38.649: V/arrayTemp inside while loop(337): [WIPRO, 25-Feb-13, 416.2, 425.8, 416.2, 419.1]
03-03 02:35:38.649: V/Results stored(337): [[WIPRO, 25-Feb-13, 416.2, 425.8, 416.2, 419.1], [WIPRO, 25-Feb-13, 416.2, 425.8, 416.2, 419.1], [WIPRO, 25-Feb-13, 416.2, 425.8, 416.2, 419.1]]
03-03 02:35:38.649: V/arrayTemp inside while loop(337): [WIPRO, 22-Feb-13, 404.5, 418.45, 403.15, 415.95]
03-03 02:35:38.654: V/Results stored(337): [[WIPRO, 22-Feb-13, 404.5, 418.45, 403.15, 415.95], [WIPRO, 22-Feb-13, 404.5, 418.45, 403.15, 415.95], [WIPRO, 22-Feb-13, 404.5, 418.45, 403.15, 415.95], [WIPRO, 22-Feb-13, 404.5, 418.45, 403.15, 415.95]]
03-03 02:35:38.654: V/arrayTemp inside while loop(337): [ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90]
03-03 02:35:38.654: V/Results stored(337): [[ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90], [ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90], [ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90], [ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90], [ICICI, 25-Feb-13, 1,099.00, 1,101.85, 1,081.20, 1,093.90]]
03-03 02:35:38.654: V/arrayTemp inside while loop(337): [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55]
03-03 02:35:38.654: V/Results stored(337): [[ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55], [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55], [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55], [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55], [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55], [ICICI, 22-Feb-13, 1,077.05, 1,099.00, 1,077.05, 1,092.55]]
03-03 02:35:38.666: V/arrayTemp inside while loop(337): [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15]
03-03 02:35:38.666: V/Results stored(337): [[TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15], [TATA MOTORS, 25-Feb-13, 296.8, 301.25, 295.1, 299.15]]
03-03 02:35:38.666: V/arrayTemp inside while loop(337): [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9]
03-03 02:35:38.666: V/Results stored(337): [[TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9], [TATA MOTORS, 22-Feb-13, 294.95, 297.55, 289.85, 292.9]]
03-03 02:35:38.674: V/arrayTemp inside while loop(337): [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55]
03-03 02:35:38.674: V/Results stored(337): [[NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55], [NESTLE, 25-Feb-13, 4,606.40, 4,689.90, 4,600.00, 4,654.55]]
03-03 02:35:38.674: V/arrayTemp inside while loop(337): [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10]
03-03 02:35:38.684: V/Results stored(337): [[NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10], [NESTLE, 22-Feb-13, 4,644.65, 4,747.70, 4,608.00, 4,629.10]]
03-03 02:35:38.684: V/arrayTemp inside while loop(337): [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85]
03-03 02:35:38.684: V/Results stored(337): [[RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85], [RANBAXY, 25-Feb-13, 422, 435, 422, 433.85]]
03-03 02:35:38.694: V/arrayTemp inside while loop(337): [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55]
03-03 02:35:38.704: V/Results stored(337): [[RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55], [RANBAXY, 22-Feb-13, 412.5, 417, 411.1, 413.55]]
03-03 02:35:38.704: V/arrayTemp inside while loop(337): [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35]
03-03 02:35:38.704: V/Results stored(337): [[REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35], [REDDY, 25-Feb-13, 1,805.00, 1,814.00, 1,791.55, 1,804.35]]
03-03 02:35:38.714: V/arrayTemp inside while loop(337): [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20]
03-03 02:35:38.724: V/Results stored(337): [[REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20], [REDDY, 22-Feb-13, 1,815.00, 1,824.95, 1,790.10, 1,816.20]]
03-03 02:35:38.724: V/arrayTemp inside while loop(337): [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45]
03-03 02:35:38.735: V/Results stored(337): [[HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45], [HDFC, 25-Feb-13, 663.25, 665.2, 654.1, 656.45]]
03-03 02:35:38.735: V/arrayTemp inside while loop(337): [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3]
03-03 02:35:38.744: V/Results stored(337): [[HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3], [HDFC, 22-Feb-13, 662.2, 666.4, 657.55, 659.3]]
03-03 02:35:38.744: V/arrayTemp inside while loop(337): [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10]
03-03 02:35:38.754: V/Results stored(337): [[MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10], [MARUTI, 25-Feb-13, 1,442.00, 1,459.90, 1,438.25, 1,444.10]]
03-03 02:35:38.764: V/arrayTemp inside while loop(337): [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40]
03-03 02:35:38.774: V/Results stored(337): [[MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40], [MARUTI, 22-Feb-13, 1,463.40, 1,467.00, 1,430.10, 1,438.40]]
03-03 02:35:38.774: V/arrayTemp inside while loop(337): [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7]
03-03 02:35:38.785: V/Results stored(337): [[HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7], [HUL, 25-Feb-13, 456.05, 457.8, 450, 451.7]]
03-03 02:35:38.785: V/arrayTemp inside while loop(337): [HUL, 22-Feb-13, 467, 467.15, 454, 455.4]
03-03 02:35:38.804: V/Results stored(337): [[HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4]]
03-03 02:35:38.814: V/Final Results(337): [[HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4], [HUL, 22-Feb-13, 467, 467.15, 454, 455.4]]
答案 0 :(得分:0)
为什么不用表结构创建POJO类? 喜欢
Class TestClass{
private String symbol;
private String date;
//etc
}
现在创建一个arraylist来包含这种类型的对象,如
public ArrayList<TestClass> results=new ArrayList<TestClass>();
答案 1 :(得分:0)
发生此行为是因为您没有在arrTemp
中存储results
的副本,而只是存储引用。您始终在同一个对象上操作,而不是单独的列表。现在,每次在while循环中调用arrTemp.clear()
时,您实际上都在清除results
中存储的引用。然后,您将新值添加到arrTemp
,然后再次向arrTemp
添加对results
的另一个引用,从而导致对{{1}中相同列表的两个(三个,四个......)相同的引用1}}。
一个简单的解决方案是不将results
声明为成员变量,而是在while循环中声明如下:
arrTemp