while(it.hasNext()){
    computerinfo computer=(computerinfo)it.next();
    //print code
}

解决方案 »

  1.   

    nod
    hasnext
    转换成你要的对象就可以了阿
      

  2.   

    添加元素的代码是这样的,我现在一共有两行代码,我试了一下,这段代码也执行了两遍阿public class GetCustomerInfo
    {
    private Connection conn=null;
    private ResultSet rs=null;
    private Statement stmt=null;
    private String sql="select * from customers";
    private List al=new ArrayList();

    public List getCustomerInfo()
    {
    try
    {
    IDBConnect dbc=new SQLDBConnect();
    conn=dbc.getConnection();

    stmt=conn.createStatement();
    stmt.execute("use Computer");
    rs=stmt.executeQuery(sql);

    while(rs.next())
    {
    CustomerVO customer=new CustomerVO(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getDate(8));
    al.add(customer);
    }
    }
    catch(SQLException ex)
    {
    ex.printStackTrace();
    }
    catch(Exception ex)
    {
    ex.printStackTrace();
    }
    finally
    {
    try
    {
    if(conn!=null)
    conn.close();
    if(stmt!=null)
    stmt.close();
    if(rs!=null)
    rs.close();
    }
    catch(SQLException ex)
    {
    ex.printStackTrace();
    }
    }
    return al;
    }
    }