知道表的数据个数
用for直接赋值

解决方案 »

  1.   

    for(int i=0; i<数组.length; i++){
        数组[i] = 表里数据;
    }
      

  2.   

    下面函数中Op.rs()已定义用于得到一个记录集
        public static String[][] rslist(String sql){
            ResultSet rs=Op.rs(sql);
            ResultSetMetaData cl = null;
            try {
                cl = rs.getMetaData();
            } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            int colsnum = 0;
            try {
                colsnum = cl.getColumnCount();
            } catch (SQLException e2) {
                // TODO Auto-generated catch block
                e2.printStackTrace();
            }
            String a[] = new String[colsnum];
            for (int i = 1; i <= colsnum; i++) {
                try {
                    a[i - 1] = cl.getColumnName(i);
                } catch (SQLException e3) {
                    // TODO Auto-generated catch block
                    e3.printStackTrace();
                }
            }
            int rowsnum = 0;
            try {
                while (rs.next()) {
                    rowsnum++;
                }
            } catch (SQLException e3) {
                // TODO Auto-generated catch block
                e3.printStackTrace();
            }
            String[][] result = new String[rowsnum][colsnum];
            try {
                rs.close();
            } catch (SQLException e4) {
                // TODO Auto-generated catch block
                e4.printStackTrace();
            }
            rs=Op.rs(sql);
            try {
                while (rs.next()) {
                    for (int k = 0; k < colsnum; k++) {
                        result[rs.getRow() - 1][k] = rs.getString(a[k]);
                    }
                }
            } catch (SQLException e6) {
                // TODO Auto-generated catch block
                e6.printStackTrace();
            }
            try {
    rs.close();
    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
            return result;
    }
      

  3.   

    是循环吗?单循环还是可逆循环?如果你所谓的循环是我所理解的循环(起点 -> i++ -> 终点 -> 起点),那么就可以用do while{ ...if() {...} ...break;}这样可以完全满足你的要求啊!
      

  4.   

    用ArrayList不就结了。
    想多长就多长