Java Map特性学习

package map;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class MapTypeTest {

    public static void main(String[] args) {
        // HashMap:无序、线程不安全
//        Map map = new HashMap<>();
        // Hashtable:无序、线程安全、性能差
//        Map map = new Hashtable();
        // LinkedHashMap:有序、线程不安全
//        Map map = new LinkedHashMap();
        // TreeMap:有序
//        Map map = new TreeMap();
        // ConcurrentHashMap:线程安全、性能好
        Map map = new ConcurrentHashMap();
        map.put("1", "1");
        map.put("2", "2");
        map.put("3", "3");
        map.put("4", "4");
        map.put("5", "5");
        map.put("6", "6");
        map.put("7", "7");
        map.put("8", "8");
        map.put("9", "9");
        map.put("10", "10");
        map.put("11", "11");
        map.put("12", "12");
        map.put("13", "13");
        map.put("14", "14");
        map.put("15", "15");
        map.put("16", "16");
        map.put("17", "17");
        map.put("18", "18");
        map.put("19", "19");
        map.put("20", "20");
        map.put("21", "21");
        map.put("22", "22");
        Set set = map.keySet();
        set.forEach(System.out::println);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值