Java - ArrayList - Get a value from an Array of array -
i save values database using function (i've been replaced vector, because deprecated) :
// database function public arraylist<string[]> selectquery(string query) { arraylist<string[]> v = null; string [] record; int colonne = 0; try { statement stmt = db.createstatement(); resultset rs = stmt.executequery(query); v = new arraylist<string[]>(); resultsetmetadata rsmd = rs.getmetadata(); colonne = rsmd.getcolumncount(); while(rs.next()) { record=new string[colonne]; (int i=0; i<colonne; i++) record[i] = rs.getstring(i+1); v.add((string[])record); } rs.close(); stmt.close(); } catch (exception e) { e.printstacktrace(); errore = e.getmessage(); } return v; } // here print result, after call function arraylist db_result=null; db_result=mydb.selectquery("select titolo, user, date articles category='1' order id asc"); int i=0; while (i<db_result.size() ) { affitta_3.createlabel().setlabel(db_result.get(i)[0]); affitta_3.createlabel().setlabel(db_result.get(i)[1]); affitta_3.createlabel().setlabel(db_result.get(i)[2]); affitta_3.createlabel().setlabel(db_result.get(i)[3]); i++; }
so, save many string-array in array. now, how can (for example) 4° value 2° array string?
why bothering clone string array when nothing else have reference it?
anyway, you'd @ string using:
string value = v.get(1)[3];
(assuming v
of type list<string[]>
or similar).
Comments
Post a Comment