Skip to content

Commit ba34dd6

Browse files
committed
update
1 parent 9867eec commit ba34dd6

File tree

6 files changed

+105
-0
lines changed

6 files changed

+105
-0
lines changed

.classpath

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
</classpathentry>
99
<classpathentry kind="lib" path="/var/www/java/javaTutorial/jedis-1.5.2.jar"/>
1010
<classpathentry kind="lib" path="/var/www/java/javaTutorial/mysql-connector.jar"/>
11+
<classpathentry kind="lib" path="/var/www/java/jackson-annotations-2.9.5.jar"/>
12+
<classpathentry kind="lib" path="/var/www/java/jackson-core-2.9.5.jar"/>
13+
<classpathentry kind="lib" path="/var/www/java/jackson-databind-2.9.5.jar"/>
1114
<classpathentry kind="output" path="bin"/>
1215
</classpath>

bin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/kevinGates/

bin/kevinCollection/Set.class

1.06 KB
Binary file not shown.

src/kevinCollection/Set.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package kevinCollection;
2+
import java.util.*;
3+
4+
public class Set {
5+
6+
public static void main(String[] args) {
7+
// TODO Auto-generated method stub
8+
setString();
9+
}
10+
11+
public static void setInteger() {
12+
Set<Integer> a = new HashSet<Integer>();
13+
a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0}));
14+
Set<Integer> b = new HashSet<Integer>();
15+
b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5}));
16+
17+
// To find union
18+
Set<Integer> union = new HashSet<Integer>(a);
19+
union.addAll(b);
20+
System.out.print("Union of the two Set");
21+
System.out.println(union);
22+
23+
24+
}
25+
26+
public static void setString() {
27+
// TODO Auto-generated method stub
28+
Set<String> hash_Set = new HashSet<String>();
29+
hash_Set.add("Geeks");
30+
hash_Set.add("For");
31+
hash_Set.add("Geeks");
32+
hash_Set.add("Example");
33+
hash_Set.add("Set");
34+
System.out.print("Set output without the duplicates");
35+
36+
System.out.println(hash_Set);
37+
38+
// Set deonstration using TreeSet
39+
System.out.print("Sorted Set after passing into TreeSet");
40+
Set<String> tree_Set = new TreeSet<String>(hash_Set);
41+
System.out.println(tree_Set);
42+
}
43+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package kevinGates.fasterxml.jackson;
2+
3+
4+
import java.io.IOException;
5+
import java.util.HashMap;
6+
import java.util.Map;
7+
8+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
9+
import com.fasterxml.jackson.core.JsonParseException;
10+
import com.fasterxml.jackson.databind.JsonMappingException;
11+
import com.fasterxml.jackson.databind.ObjectMapper;
12+
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
13+
import com.fasterxml.jackson.databind.SerializationFeature;
14+
import com.fasterxml.jackson.databind.cfg.MapperConfig;
15+
import com.fasterxml.jackson.databind.introspect.AnnotatedField;
16+
import com.fasterxml.jackson.databind.introspect.AnnotatedMethod;
17+
18+
19+
public class Basic {
20+
21+
public static void main(String[] args) throws JsonParseException, JsonMappingException, IOException {
22+
// TODO Auto-generated method stub
23+
objectMapper();
24+
toMap();
25+
}
26+
27+
public static void objectMapper() throws JsonParseException, JsonMappingException, IOException {
28+
System.out.println("start");
29+
ObjectMapper mapper = new ObjectMapper(); // create once, reuse
30+
31+
MyValue user = mapper.readValue("{\"name\":\"billgates\", \"age\":28}", MyValue.class);
32+
33+
System.out.println(user.name);
34+
System.out.println(user.age);
35+
36+
System.out.println("end");
37+
}
38+
39+
public static void toMap() throws JsonParseException, JsonMappingException, IOException {
40+
System.out.println("start toMap");
41+
ObjectMapper mapper = new ObjectMapper(); // create once, reuse
42+
43+
Map<String, Integer> user = mapper.readValue("{\"name\":\"billgates\", \"age\":28}", Map.class);
44+
45+
System.out.println(user);
46+
47+
System.out.println("end");
48+
}
49+
}
50+
51+
52+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package kevinGates.fasterxml.jackson;
2+
3+
public class MyValue {
4+
public String name;
5+
public int age;
6+
}

0 commit comments

Comments
 (0)