摘要:
1 package p2; 2 3 //import static java.util.Collections.max; 4 5 import java.util.ArrayList; 6 import static java.util.Collections.*; //静态导入,其实导入的是类中的静态成员 7 import java.util.List; 8 import ...
阅读全文
posted @ 2016-09-05 20:03
Newbie蔡
阅读(200)
推荐(0)
编辑
摘要:
1 package p2; 2 3 public class ParamterDemo { 4 5 public static void main(String[] args) { 6 7 int sum1 = add(4,5); 8 int sum2 = add(4,5,6); 9 int sum3...
阅读全文
posted @ 2016-09-05 19:47
Newbie蔡
阅读(216)
推荐(0)
编辑
摘要:
1 package p2; 2 3 import java.util.ArrayList; 4 import java.util.HashMap; 5 import java.util.List; 6 import java.util.Map; 7 8 public class ForEachDemo { 9 10 public static void main(...
阅读全文
posted @ 2016-09-05 19:32
Newbie蔡
阅读(596)
推荐(0)
编辑
摘要:
1 package p2; 2 3 import java.util.ArrayList; 4 import java.util.Arrays; 5 import java.util.List; 6 7 public class ToArray { 8 9 public static void main(String[] args) { 10 1...
阅读全文
posted @ 2016-09-05 17:51
Newbie蔡
阅读(4105)
推荐(0)
编辑
摘要:
1 package p2; 2 3 import java.util.Arrays; 4 import java.util.List; 5 6 public class ArraysDemo { 7 8 public static void main(String[] args) { 9 /* 10 * Arrays:集合框架的工...
阅读全文
posted @ 2016-09-05 17:37
Newbie蔡
阅读(207)
推荐(0)
编辑
摘要:
1 package cn.itcast.p2.toolclass.collections.demo; 2 3 import java.util.ArrayList; 4 import java.util.Collections; 5 import java.util.Comparator; 6 import java.util.List; 7 import java...
阅读全文
posted @ 2016-09-05 16:38
Newbie蔡
阅读(659)
推荐(0)
编辑
摘要:
TreeMap,与TreeSet类似,可以对集合中的元素进行排序,同时保持元素的唯一性。 应注意,Comparable(实现接口,记得覆盖comparaTo方法),Comparator的使用。
阅读全文
posted @ 2016-09-05 16:28
Newbie蔡
阅读(977)
推荐(0)
编辑
摘要:
类Collections的静态方法 此类完全由在 collection 上进行操作或返回 collection 的静态方法组成。 排序 static <T extends Comparable<? super T>> void sort(List<T> list) static <T> void s
阅读全文
posted @ 2016-09-05 15:45
Newbie蔡
阅读(658)
推荐(0)
编辑
摘要:
1 package cn.itcast.p1.map.test; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 public class MapTest2 { 7 8 public static void main(String[] args) { 9 /* 10 ...
阅读全文
posted @ 2016-09-05 14:56
Newbie蔡
阅读(709)
推荐(0)
编辑
摘要:
1 package cn.itcast.p1.map.test; 2 3 import java.util.Iterator; 4 import java.util.Map; 5 import java.util.TreeMap; 6 /*练习: 7 * 打印结果:a(1) b(2) c(3)... 8 * 思路: 9 * 对于结果的分析发现,字母和次数之间存在着映...
阅读全文
posted @ 2016-09-05 14:55
Newbie蔡
阅读(4298)
推荐(0)
编辑
摘要:
特点: 存入元素的顺序 与 取出元素的顺序相同(与LinkedHashSet类似)
阅读全文
posted @ 2016-09-05 14:50
Newbie蔡
阅读(215)
推荐(0)
编辑
摘要:
1 import java.util.Collection; 2 import java.util.HashMap; 3 import java.util.Iterator; 4 import java.util.Map; 5 import java.util.Set; 6 7 public class MapDemo { 8 9 public static voi...
阅读全文
posted @ 2016-09-05 14:49
Newbie蔡
阅读(3782)
推荐(0)
编辑
摘要:
存储在HashMap集合中的元素,必须覆盖hashCode和equals方法(与HashSet类似)
阅读全文
posted @ 2016-09-05 14:46
Newbie蔡
阅读(399)
推荐(0)
编辑
摘要:
Map: 一次添加一对元素,也称为双列集合。 而Collection,一次添加一个元素,称为单列集合。 常用方法: 1.添加 value put(key,value); 返回前一个与key关联的值,如果没有,返回null。 2.删除 void clear(); 清空map集合。 value remo
阅读全文
posted @ 2016-09-05 14:45
Newbie蔡
阅读(200)
推荐(0)
编辑