1.if(String.indexOf("?") == -1)
    不存在;
   else
     存在;2.没看懂

解决方案 »

  1.   

    String str = "kdfj?";
    int i = str.indexOf("j");
     if (i > 0)  existed;
     else not existed;
      

  2.   

    谢谢了,还有:
    如何将一些HashMap装入一个数组中,在数组取出来之后仍然返回HashMap
      

  3.   

    searchResult = DBconn.executeQuery(sql);
            HashMap rows = new HashMap();
            try{
                ResultSetMetaData rsmd = searchResult.getMetaData();
                int columnCount = rsmd.getColumnCount();
                while (searchResult.next()) {
                    HashMap row = new HashMap();
                    int i=1;
                    for (i = 1; i <= columnCount; i++) {
                        String name = rsmd.getColumnName(i);
                        row.put(name, searchResult.getObject(i));
                        rows.putAll(row);
                    }
                }
                System.out.println(rows);
            }
    就是想上面的代码,如何把row装入一个数组,并且返回呢,返回以后也可以取得rows.get(0).get("property")的值呢?,或者其他方式如果能解决这个问题也可以
      

  4.   

    我是个菜鸟,问题不知道如何描述,总之呢就是希望从数据库中取出来结果以后返回一个数组
    如下rows[0][field1]--->test01
        [0][field2]--->test02
        [1][field1]--->test11
        [1][field2]--->test12
      

  5.   

    用ArrayList,如下:searchResult = DBconn.executeQuery(sql);
            ArrayList rows = new ArrayList();
            try{
                ResultSetMetaData rsmd = searchResult.getMetaData();
                int columnCount = rsmd.getColumnCount();
                while (searchResult.next()) {
                    HashMap row = new HashMap();
                    int i=1;
                    for (i = 1; i <= columnCount; i++) {
                        String name = rsmd.getColumnName(i);
                        row.put(name, searchResult.getObject(i));
                    }
                    rows.add(row);
                }            for(int i=0; i<rows.size(); i++)
                {
                     System.out.println("rows[" + i + "][field1]=" + rows.get(i).get("field1"));
                     System.out.println("rows[" + i + "][field1]=" + rows.get(i).get("field2"));
                }
            }
      

  6.   

    后面部分应该是:
                for(int i=0; i<rows.size(); i++)
                {
                     System.out.println("rows[" + i + "][field1]=" + ((HashMap)rows.get(i)).get("field1"));
                     System.out.println("rows[" + i + "][field1]=" + ((HashMap)rows.get(i)).get("field2"));
                }