关于Vector的问题

andiyang ActiveChina IT运维总监  2001-08-29 09:18:27
public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException {

PrintWriter out = response.getWriter();

try{

Vector V = new Vector();
String[] row = new String[5];
String Login_UID = "1";
String Oper_CN = "1" ;
String oper_cno = request.getParameter("oper_cno");
String oper_uid = request.getParameter("oper_uid");

String[] check = request.getParameterValues("ch");
String[] s = request.getParameterValues("role_name");
String[] k = request.getParameterValues("role_describe");

String t0;
for (int j=0;j<check.length;j++)
{
//准备数据
row[0] = s[Integer.parseInt(check[j])];
row[1] = Oper_CN;
row[2] = Oper_CN;
row[3] = oper_cno;
row[4] = oper_uid;
V.addElement(row);
t0 = ((String[])V.elementAt(j))[0];

out.println(t0+"<br>");
//out.println("<br>"+check[i]+" ");
//out.println(s[util.stringToInt(check[i])]+" ");
//out.println(k[util.stringToInt(check[i])]+"<br>");

}
out.println("<font color=red>"+V.size()+"</font><br>");
for(int i=0;i<V.size();i++)
{
out.println(i);
t0 = ((String[])V.elementAt(i))[0];

// t0 = (String)V.elementAt(i);
out.println(t0+"<br>");

}
}catch(Throwable ex){
out.println(ex.toString());

}


}
看看输出:

2
11
0001
3
4
0 3
1 3
2 3
3 3
...全文
42 点赞 收藏 2
写回复
2 条回复
lp_dragon 2001年08月30日
lovesnoopy(洋葱头)对,你往Vector V中加的是指向同一个对象的check.length个不同的handle
回复 点赞
lovesnoopy 2001年08月29日
String t0;
for (int j=0;j<check.length;j++)
{
//准备数据
String[] row = new String[5]; //----------notice here
row[0] = s[Integer.parseInt(check[j])];
row[1] = Oper_CN;
row[2] = Oper_CN;
row[3] = oper_cno;
row[4] = oper_uid;
V.addElement(row);
......
}
..........
回复 点赞
发动态
发帖子
Java SE
创建于2007-09-28

3.4w+

社区成员

30.7w+

社区内容

Java 2 Standard Edition
社区公告
暂无公告