java_Vector类的使用

package collection;
import java.util.Iterator;
import java.util.Vector;
public class VectorDemo {
public static void main(String[] args) {
/*Vector不用像泛型类<>那样,定义Vector对象容积是不立即指定Vector容器里面元素的类型;*/
Vector strs = new Vector(10, 10);
/*Vector类几乎和ArrayList类一样(就是慢,定义对象时不指定类型参数)*/
strs.add("str1");
strs.add("str2");
strs.add("str3");
strs.add("str4");
strs.add("str5");
System.out.println(strs.toString());
String str = (String) strs.elementAt(0);
strs.set(2, "new str2");
strs.remove("str4");
Iterator<String> it = strs.iterator();
while (it.hasNext())
System.out.print(it.next() + " ");
}
}
posted @   xuchaoxin1375  阅读(7)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2023-08-30 AA@多项式@余式定理@根和一次因式的关系
2021-08-30 python随机数模块@numpy@随机数RandomGenerator@生成指定范围内的随机数序列@js随机数
点击右上角即可分享
微信分享提示