collection framework(map)

hashmap:

常用方法:

package map;

import org.junit.Test;

import java.nio.charset.IllegalCharsetNameException;
import java.util.HashMap;
import java.util.HashSet;

public class MapTest {
@Test
//hashmap不能重复无序
public void test1(){
HashMap<Integer,String> map = new HashMap<>();
//添加数据<key,value>key必须唯一不能重复
map.put(1,"zrm");
map.put(2,"fjx");
map.put(3,"czy");
//查看map里面是否含有此数据
map.containsKey(4);
//delete data
String v = map.remove(1);
map.remove(1,"zrm");
//修改,map里面没有用于修改的方法,直接用put()方法覆盖就可以
//根据key查看value
map.get(2);
System.out.println(map);

}
}

遍历map:
package map;

import org.junit.Test;

import java.nio.charset.IllegalCharsetNameException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class MapTest {
@Test
//hashmap不能重复无序
public void test1() {
HashMap<Integer, String> map = new HashMap<>();
//添加数据<key,value>key必须唯一不能重复
map.put(1, "zrm");
map.put(2, "fjx");
map.put(3, "czy");
//查看map里面是否含有此数据
map.containsKey(4);
//delete data
String v = map.remove(1);
map.remove(1, "zrm");
//修改,map里面没有用于修改的方法,直接用put()方法覆盖就可以
//根据key查看value
map.get(2);
System.out.println(map);
//对hashmap遍历,要先把map转换成set
for (Map.Entry<Integer, String> map1 : map.entrySet()) {
System.out.println(map1);
}
}
}

转载于:https://www.cnblogs.com/zrmj/p/11420351.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This book explores the concept of a map as a fundamental data type. It defines maps at three levels. The first is an abstract level, in which mathematic concepts are leveraged to precisely explain maps and operational semantics. The second is at a discrete level, in which graph theory is used to create a data model with the goal of implementation in computer systems. Finally, maps are examined at an implementation level, in which the authors discuss the implementation of a fundamental map data type in database systems. The map data type presented in this book creates new mechanisms for the storage, analysis, and computation of map data objects in any field that represents data in a map form. The authors develop a model that includes a map data type capable of representing thematic and geometric attributes in a single data object. The book provides a complete example of mathematically defining a data type, ensuring closure properties of those operations, and then translating that type into a state that is suited for implementation in a particular context. The book is designed for researchers and professionals working in geography or computer science in a range of fields including navigation, reasoning, robotics, geospatial analysis, data management, and information retrieval. Table of Contents Chapter 1 Concepts of Maps Chapter 2 A Formal Model of Maps as a Fundamental Type Chapter 3 PLR Partitions: Extending Maps to Include Point and Line Features Chapter 4 Foundational Operations for Maps Chapter 5 Constructing Map Operations Using the Fundamental Map Operations Chapter 6 Extended Operations Over Maps Chapter 7 Topological Relationships Between Maps Chapter 8 A Discrete Model of Maps Chapter 9 Implementing Maps: Map2D

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值