有个关于vector的问题?

dengzi725 2003-12-10 07:01:59
从jsp页面中提交一堆不知道长度的相当于一个数组的信息。然后要在一个java文件中获得这个一堆数据,想把它方在vector中。不知道怎么把这些数据方到vector中,以及怎么样在获得使用这些数据。
请教!
Vector receivedX=new Vector();
Vector receivedY=new Vector();
receivedX.addElement(this.getParameter("datax"));
receivedY.addElement(this.getParameter("datay"));
其中datax,datay就是从jsp页面中传入的一堆int型的text值。
现在不知道怎么样在java中把这些int值取出来?
...全文
49 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
gao277 2003-12-10
  • 打赏
  • 举报
回复
Integer.parseInt(a);
这里a是String

你应该先get出来然后在转换为String,然后在转化成int
Shawn和月 2003-12-10
  • 打赏
  • 举报
回复
Object 转换为 Integer 时,有可能会产生 CastClassException (类转换异常),因此要注意该对象到底是否为 Integer。
Shawn和月 2003-12-10
  • 打赏
  • 举报
回复
try{
//String to int
int datax = Integer.parseInt(request.getParameter("datax"));
//int to Object
receivedX.add(new Integer(datax));
}
catch(NumberFormatException nfe){
//...
}

//Object to int
int datax = Integer.intValue((Integer)receivedX.get(0));
dengzi725 2003-12-10
  • 打赏
  • 举报
回复
还有呢?就是怎么样把一个object转换成int型?
怎么样把一个string转化成int型?

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧