Skip to content

Commit 7acb389

Browse files
committed
🍱 add java8 growing code
1 parent 0d2f2f1 commit 7acb389

File tree

12 files changed

+161
-0
lines changed

12 files changed

+161
-0
lines changed

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/AutoBoxing.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/**
44
* 自动装箱、拆箱
5+
*
6+
* @author biezhi
7+
* @date 2018/2/8
58
*/
69
public class AutoBoxing {
710

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/Concurrent.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
/**
1212
* 并发库
13+
*
14+
* @author biezhi
15+
* @date 2018/2/8
1316
*/
1417
public class Concurrent {
1518

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/EnumDemo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
/**
44
* 枚举
5+
*
6+
* @author biezhi
7+
* @date 2018/2/8
58
*/
69
public enum EnumDemo {
710

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/ForEach.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
/**
77
* for each
8+
*
9+
* @author biezhi
10+
* @date 2018/2/8
811
*/
912
public class ForEach {
1013

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/Generic.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55

66
/**
77
* 泛型
8+
*
9+
* @author biezhi
10+
* @date 2018/2/8
811
*/
912
public class Generic<T> {
1013

14+
public T getById(Integer id){
15+
return null;
16+
}
17+
1118
public static void main(String[] args) {
1219

1320
Map<String, Integer> map = new HashMap<>();

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/StaticImport.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
/**
66
* 静态导入
7+
*
8+
* @author biezhi
9+
* @date 2018/2/8
710
*/
811
public class StaticImport {
912

java8-growing/src/main/java/io/github/biezhi/java8/growing/jdk5/VarArgs.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
/**
77
* 变长参数
8+
*
9+
* @author biezhi
10+
* @date 2018/2/8
811
*/
912
public class VarArgs {
1013

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.github.biezhi.java8.growing.jdk7;
2+
3+
import java.io.BufferedReader;
4+
import java.io.FileReader;
5+
import java.io.IOException;
6+
import java.sql.Connection;
7+
import java.sql.SQLException;
8+
import java.sql.Statement;
9+
10+
/**
11+
* 捕获多异常
12+
*
13+
* @author biezhi
14+
* @date 2018/2/8
15+
*/
16+
public class CatchMultiException {
17+
18+
public static void main(String[] args) {
19+
try {
20+
BufferedReader reader = new BufferedReader(new FileReader(""));
21+
Connection con = null;
22+
Statement stmt = con.createStatement();
23+
} catch (IOException | SQLException e) {
24+
//捕获多个异常,e就是final类型的
25+
e.printStackTrace();
26+
}
27+
}
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.github.biezhi.java8.growing.jdk7;
2+
3+
/**
4+
* 数字下划线支持
5+
*
6+
* @author biezhi
7+
* @date 2018/2/8
8+
*/
9+
public class NumericUnderline {
10+
11+
public static void main(String[] args) {
12+
int num = 1234_5678_9;
13+
float num2 = 222_33F;
14+
long num3 = 123_000_111L;
15+
long tenSenconds = 10_000L;
16+
}
17+
18+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.biezhi.java8.growing.jdk7;
2+
3+
import io.github.biezhi.java8.growing.jdk5.EnumDemo;
4+
5+
/**
6+
* switch对String的支持
7+
*
8+
* @author biezhi
9+
* @date 2018/2/8
10+
*/
11+
public class SwitchString {
12+
13+
public static void main(String[] args) {
14+
String bis = "java";
15+
switch (bis) {
16+
case "java":
17+
break;
18+
case "python":
19+
break;
20+
case "ruby":
21+
break;
22+
default:
23+
break;
24+
}
25+
26+
EnumDemo enumDemo = EnumDemo.GREEN;
27+
28+
switch (enumDemo) {
29+
case RED:
30+
break;
31+
case YELLOW:
32+
break;
33+
default:
34+
break;
35+
}
36+
37+
}
38+
39+
}

0 commit comments

Comments
 (0)