`
xuepengcheng
  • 浏览: 46725 次
  • 性别: Icon_minigender_1
  • 来自: 郴州
社区版块
存档分类
最新评论

ArrayIndexOutOfBoundsException

J# 
阅读更多
在ClicentInt类中使用Vector类,它是可以实现可增长对象数组。与数组一样,它包含可以使用整数索引进行访问的组件。但是,Vector的大小可以根据需要增大或缩小,以适应创建Vector后进行添加或移除项的操作。在程序中使用capacity函数来确定容量大小,错使访问起界出现异常。capacity始终到少应与向量的大小相等;这个值通常比后者大些,因为随着将组件添加到向量中,其存储将按capacityIncrement的大小增加储块。


Vector vector1 = (Vector)streamFromServer.readObject();

System.out.print(vector1.capacity());   //10
System.out.print(vector1.size());       //2
for(int j=0;j<vector1.capacity();j++)
{

   txtListUsers.append((String)vector1.elementAt(j));
   txtListUsers.append("\n");

}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics