Question: I was processing my `resultset` to get the details. I need to return an `ArrayList`, so how can I put the key,values from the `resultset` to any of the collection objects and then put the same to an `ArrayList`?

Here is the code:

```
public List<Bike> addBikes() throws ClassNotFoundException, SQLException{
        List<Bike> bikeList = new ArrayList<Bike>();

        Class.forName("com.mysql.jdbc.Driver");
        Connection con  = null;
        Statement  stm = null;
        ResultSet rs = null;
        con=DriverManager.getConnection("jdbc:mysql://localhost:3306/spring_hibernate","root","root"); ;
        stm=con.createStatement(); 
        String qry="Select * from bike"; 
        rs=stm.executeQuery(qry);
        while(rs.next())
        {           
            /* I need to put   
             * rs.getString("name"),rs.getString("model")
             * etc into any of the suitable collection objects 
             * and then need to add those to the ArrayList - bikeList
             * 
             */

        }
        return bikeList;

    }

```

Answer: 
For each result in the result set, create a `new Bike()` and copy the values from that result to the new bikes fields. At the end, add the bike to the list.

```
Bike bike = new Bike()
bike.setName(rs.getString("name"));
//...
bikeList.add(bike);

```
You have Banana in your hand..just eat it :) 

Create a empty list and in iteration Create new Bike and add into the List.

```
 List<Bike> bikes  = new ArrayList<Bikes>();
  while(rs.next())
        {           
           Bike bike = new Bike();
           bike.setname( rs.getString("name"));
           //other properties
           bikes.add(bike);
        }

    return bikes;

```