-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrintingContainer.java
More file actions
45 lines (36 loc) · 1.23 KB
/
PrintingContainer.java
File metadata and controls
45 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package algrothm;
import sun.security.x509.AttributeNameEnumeration;
import java.util.*;
import static jdk.nashorn.internal.objects.Global.print;
/**
* Created by wr on 2018/10/16.
*
* 多态的调用的一种方法
*
*/
public class PrintingContainer {
static Collection fill(Collection<String> collection){
collection.add("rat");
collection.add("cat");
collection.add("dog");
collection.add("dog");
return collection;
}
static Map fill(Map<String,String> map) {
map.put("rat","Fuzzy");
map.put("cat","Rags");
map.put("dog","Bosco");
map.put("dog","Spot");
return map;
}
public static void main(String [] args) {
System.out.println(fill(new ArrayList<String>()));
System.out.println(fill(new LinkedList<String>()));
System.out.println(fill(new HashSet<String>()));
System.out.println(fill(new TreeSet<String>()));
System.out.println(fill(new LinkedHashSet<String>()));
System.out.println(fill(new HashMap<String, String>()));
System.out.println(fill(new TreeMap<String, String>()));
System.out.println(fill(new LinkedHashMap<String, String>()));
}
}