首页 文章 精选 留言 我的

精选列表

搜索[文件转换工具],共10000篇文章
优秀的个人博客,低调大师

List、Set、Map、数组之间各种转换

刚学Java不久的时候,接到一个电面,然后问了一些java的知识,比如说Java的编码,Unicode等,但是最让我蛋疼的是怎么吗map转为set,那个时候对集合用的很少,对集合不是特别了解,map还知道,set就蒙了,然后转为set更蒙了,觉得应该有API提供吧,但是不知道怎么说。后来我一直下来再查这个问题,查到了,但是没有实践过,今天我就来一发代码。 List转Set Set set = new HashSet(new ArrayList()); Set转List List list = new ArrayList(new HashSet()); 数组转为List List arr = Arrays.asList("1", "2", "3"); //或者 String[] arr = {"1", "2"}; List list = Arrays.asList(arr); 数组转为Set int[] arr = { 1, 2, 3 }; Set set = new HashSet(Arrays.asList(arr)); Map的值转化为List List list = new ArrayList(map.values()); Map的值转化为Set Set set = new HashSet(map.values()); List转数组 List list = Arrays.asList("a","b"); String[] arr = (String[])list.toArray(new String[list.size()]); 代码 public class listsetmao { private static List<String> arrayList; private static Map<String, String> hashMap; private static Set<String> hashSet; private static String[] arr = {"11oneone","22twotwo"}; public static void main(String[] args) { /* * //list转set initList(); Set<String> set = new * HashSet<String>(arrayList); * System.out.println("arrayList.toString()--->"+set.toString()); * System.out.println("set.toString()--->"+set.toString()); */ /* * //set转list initSet(); List<String> list = new * ArrayList<String>(hashSet); * System.out.println("hashSet.toString()--->"+hashSet.toString()); * System.out.println("list.toString()--->"+list.toString()); */ /* // 数组转为list List<String> list = Arrays.asList(arr); System.out.println("list.toString()--->"+list.toString()); */ /* //数组转set Set set = new HashSet<>(Arrays.asList(arr)); System.out.println("set.toString()--->"+set.toString()); */ /* //map的值转为list initMap(); List<String> list = new ArrayList<String>(hashMap.values()); System.out.println("list.toString()--->"+list.toString()); */ /* //map的值转为set initMap(); Set<String> set = new HashSet<String>(hashMap.values()); System.out.println("set.toString()--->"+set.toString()); */ /* //map的key转为set initMap(); Set<String> set = new HashSet<String>(hashMap.keySet()); System.out.println("set.toString()--->"+set.toString()); */ //list转数组 initList(); String[] arr1 = (String[])arrayList.toArray(new String[arrayList.size()]); System.out.println("Arrays.toString(arr1)--->"+Arrays.toString(arr1)); } public static void initList() { arrayList = new ArrayList<String>(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); arrayList.add("4"); } public static void initMap() { hashMap = new HashMap<String, String>(); hashMap.put("one", "one1"); hashMap.put("two", "two2"); hashMap.put("three", "three3"); } public static void initSet() { hashSet = new HashSet<String>(); hashSet.add("1one"); hashSet.add("2two"); hashSet.add("3three"); hashSet.add("4four"); hashSet.add("5five"); } } 我是天王盖地虎的分割线 源代码:http://pan.baidu.com/s/1dD1Qx01 listsetmap.zip 本文转自我爱物联网博客园博客,原文链接:http://www.cnblogs.com/yydcdut/p/3825721.html如需转载请自行联系原作者

优秀的个人博客,低调大师

WEB测试到移动测试的转换

移动互联网的发展毋庸置疑是必然的趋势,我们曾经传统WEB互联网测试的同学,也必然走上移动测试的道路,移动测试与pc测试到底需要怎样的思维转变才能更快的进入移动节奏呢?对比下WEB与移动的测试不同点: 从测试类型看不同: 测试类型 WEB 移动 交互测试 稍轻 更注重 ,好的体验是移动互联网取胜的关键! 性能测试 接口性能页面性能前端性能 服务端系统性能客户端系统性能耗电量流量 安装与卸载测试 无 必要且重要 升级测试 无 必要且重要 功能测试 同等重要 同等重要 安全测试 常规安全 常规安全手机隐私安全 兼容性测试 浏览器兼容系统兼容性 不同安卓/IOS系统版本兼容性;不同机型兼容性 从测试过程看不同: 测试过程 WEB 移动 测试分析 系统交互图功能流程图 服务端接口分析;移动交互分析; 测试用例 功能、交互、接口用例 功能用例;客户端接口请求与服务端接口反馈用例;移

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册