zoukankan      html  css  js  c++  java
  • Java中 map.values转换为list或者string[]

        @Test
        public void testMap2List() throws Exception{
            Map<String, String> map = new HashMap<String, String>();
            map.put("1", "AA");
            map.put("2", "BB");
            map.put("3", "CC");
            map.put("4", "DD");
    
            Collection<String> valueCollection = map.values();
            final int size = valueCollection.size();
    
            List<String> valueList = new ArrayList<String>(valueCollection);
    
            String[] valueArray = new String[size];
            map.values().toArray(valueArray);
        }
    

      

  • 相关阅读:
    vue
    vim 使用
    ssh 免密码登录
    shell 监控
    shell top
    使用网络技术---WebView
    安卓数据存储
    模块
    面向对象
    文件
  • 原文地址:https://www.cnblogs.com/hqbhonker/p/5196359.html
Copyright © 2011-2022 走看看