I am automating my gui app. I am fetching the data from database here data contains 6 player and their position..and now I need to store all the data into arraylist... I need to store all the data and put into arraylist..
java.sql.Statement stm1 = con.createStatement();
java.sql.ResultSet result1 = stm1.executeQuery(player_name_pos_query);//lineup query
List<String> al1=new ArrayList<String>();
while(result1.next())
{
// System.out.println(2);
lineup_player_name=result1.getString(1);
pos=result1.getString(2);
al1.add(lineup_player_name);
al1.add(pos);
System.out.println(al1);// [Mahmood, F]
}
It is printing only last values...I want to take all values and keep it in single array
[Jermaine O'Neal, G]
How to keep it in one arrayLIST [Mohamood, F,Josh Childress, C, Corsley Edwards, G, Robert Hite, F,Nate Robinson, C, Jermaine O'Neal, G]
so I can take size of 12 and like this 0 to 12...And I can get each one by one string
Like get(0) --Mohammed, get(1)--F, get(2)--Josh Childress...
Then only I can able to click the Gui for respective player position and my loop condition would work..