免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 948 | 回复: 0
打印 上一主题 下一主题

java集合容器 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-07 16:38 |只看该作者 |倒序浏览

import java.util.*;
public class JAVAContainer {
public static void main(String[] args) throws Exception{
//ArrayList
{
ArrayList arraylist=new ArrayList();
arraylist.add(0,"end");//指定索引加入值
//需注意的是,如果现有2个值,我加入索引为5的那么就会出现异常
for(int i=0;ijava JAVAContainer
ArrayList:
0;1;end;
ArrayList's lastIndexOf("0") is 4
Arrays:
a;b;c;
Arrays's length is 3
Collections:
Fill;Fill;Fill;
[1, 2, 3]
[1, 3, 2]
EventObject:
hello
false
HashMap:
{3=a, 2=b, 0=c, 1=a}
a;b;c;a;
HashSet:
[a, c, b]
a;c;b;
Hashtable:
c;b;a;c;
IdentityHashMap:
{3=b, 1=a, 0=c, 2=a}
true
true
[3=b, 1=a, 0=c, 2=a]
[3, 1, 0, 2]
LinkedHashMap:
{0=b, 2=a, 1=c, 3=b}
true
true
b;a;c;b;
LinkedHashSet:
[c, a, b]
true
c;a;b;
LinkedList:
[d, a, c, b]
d;a;c;b;
Stack:
c;b;d;e;a;
a
a
true;false
4
TreeMap:
{0=d, 1=b, 2=a, 3=c}
0
d;b;a;c;
TreeSet:
[a, b, c, d]
a
a;b;c;d;
Vector:
[b, a, d, c]
[b, a, h, c]
b;a;h;c;
[b, a]
WeakHashMap:
{3=a, 2=c, 0=d, 1=b}
true
true
3=a;2=c;0=d;1=b;


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/27594/showart_416742.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP