java
码农进阶之路
这个作者很懒,什么都没留下…
展开
-
Map.putall()方法
将一个已有Map中的数据压入另一个Map中,且去重。public static void main(String []args){ Map map1 = new HashMap(); //定义Map集合对象 map1.put("apple", "新鲜的苹果"); //向集合中添加对象 map1.put("comput转载 2017-10-04 18:40:18 · 10871 阅读 · 0 评论 -
统计字符串再另一字符串中出现次数
第一次从零位置开始,之后从找到匹配的那个位置+匹配字符串长度后的位置开始继续找,直到从这个位置开始找不到(即为-1)public static int count(String text,String sub){ int count =0, start =0; while((start=text.indexOf(sub,start))>=0){原创 2017-10-27 20:55:00 · 926 阅读 · 0 评论