Skip to content

Commit f3facba

Browse files
codedatacodedata
authored andcommitted
added exercise5
1 parent da0ff70 commit f3facba

8 files changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#Tue Oct 22 15:53:53 CST 2013
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apply plugin: 'java'
2+
apply plugin:'application'
3+
mainClassName = "Main"
4+
5+
repositories {
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
compile group: 'com.google.guava', name: 'guava', version: '15.0'
11+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import java.util.*;
2+
import com.google.common.collect.*;
3+
import static java.lang.System.*;
4+
5+
public class Main {
6+
public static void main(String[] args) {
7+
// List Demo
8+
List<Integer> numbers = Arrays.asList(1, 2, 3);
9+
10+
List<Integer> collector =
11+
ImmutableList.<Integer>builder()
12+
.add(10)
13+
.addAll(numbers)
14+
.build();
15+
16+
out.println(collector.size()); // 4
17+
18+
// Set Demo
19+
Set<String> admins = ImmutableSet.of("Justin", "caterpillar");
20+
Set<String> users = ImmutableSet.of("momor", "hamini", "Justin");
21+
22+
out.println(admins.contains("Justin")); // 是否在站長群?true
23+
out.println(Sets.intersection(admins, users)); // 同時是站長群也是使用者群的? [Justin]
24+
out.println(Sets.union(admins, users)); // 是站長群或是使用者群的? [Justin, caterpillar, momor, hamini]
25+
out.println(Sets.difference(admins, users)); // 站長群但不使用者群的? [caterpillar]
26+
out.println(Sets.symmetricDifference(admins, users)); // xor [caterpillar, momor, hamini]
27+
out.println(admins.containsAll(users)); // ∈,false
28+
out.println(users.containsAll(admins)); // false*/
29+
30+
// Map Demo
31+
Map<String, Integer> passwords = ImmutableMap.of("Justin", 123456, "caterpillar", 93933);
32+
out.println(passwords.get("Justin")); // 123456
33+
out.println(passwords.entrySet()); // [Justin=123456, Hamimi=970221]
34+
out.println(passwords.keySet()); // [Justin, Hamimi]
35+
out.println(passwords.values()); // [123456, 970221]
36+
}
37+
}

0 commit comments

Comments
 (0)