Chinaunix首页 | 论坛 | 博客
  • 博客访问: 58045
  • 博文数量: 30
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 301
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-25 22:19
个人简介

技术成就一切

文章分类

全部博文(30)

文章存档

2019年(1)

2015年(3)

2014年(24)

2013年(2)

我的朋友

分类: Java

2014-05-23 16:29:11

1、实现Map接口的类用来存储 键值对
2、Map接口实现的类有HashMap和TreeMap等;
3、Map类中存储的键值对通过键值来标示,因此键值不能重复(equals() );

Tips:
    1、如果某个类重写equals方法,那么必须重写hashCode方法;


    2、auto-boxing/unboxing  ---  在合适的时机进行打包、解包
            自动将基础类型转变为对象;
            自动将对象转换为基础类型;
Map m1 = new HashMap();
Map m2 = new HashMap();

m1.put( "one", new Integer( "1" ) );//m1.put( "one", 1);
m1.put( "two", new Integer( "2" ) );//m1.put( "two", 2);
m1.put( "three", new Integer( "3" ) );//m1.put( "threee", 3);
m2.put( "A", new Integer( "1" ) );//m1.put( "A", 1);
m2.put( "B", new Integer( "2" ) );//m1.put( "B", 2);



阅读(553) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~