Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteafa2db

Browse files
committed
add java13
1 parentebfd990 commiteafa2db

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.jdk13;
5+
6+
importstaticjava.util.Calendar.*;
7+
8+
9+
/**
10+
* JDK13: Switch Expressions (Preview)
11+
* JEP 354: http://openjdk.java.net/jeps/354
12+
*
13+
* @since 1.0.0 2019年9月19日
14+
* @author <a href="https://waylau.com">Way Lau</a>
15+
*/
16+
classSwitchExpressionsDemo {
17+
18+
/**
19+
* @param args
20+
*/
21+
@SuppressWarnings("preview")
22+
publicstaticvoidmain(String[]args) {
23+
varday =SATURDAY;
24+
25+
// JDK12之前
26+
switch (day) {
27+
caseMONDAY:
28+
caseFRIDAY:
29+
caseSUNDAY:
30+
System.out.println(6);
31+
break;
32+
caseTUESDAY:
33+
System.out.println(7);
34+
break;
35+
caseTHURSDAY:
36+
caseSATURDAY:
37+
System.out.println(8);
38+
break;
39+
caseWEDNESDAY:
40+
System.out.println(9);
41+
break;
42+
}
43+
44+
// JDK12之后
45+
switch (day) {
46+
caseMONDAY,FRIDAY,SUNDAY ->System.out.println(6);
47+
caseTUESDAY ->System.out.println(7);
48+
caseTHURSDAY,SATURDAY ->System.out.println(8);
49+
caseWEDNESDAY ->System.out.println(9);
50+
}
51+
52+
}
53+
54+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Welcome to https://waylau.com
3+
*/
4+
packagecom.waylau.java.jdk13;
5+
6+
/**
7+
* JEP 355: Text Blocks (Preview)
8+
* JEP 355: http://openjdk.java.net/jeps/355
9+
*
10+
* @since 1.0.0 2019年9月19日
11+
* @author <a href="https://waylau.com">Way Lau</a>
12+
*/
13+
classTextBlocksDemo {
14+
15+
/**
16+
* @param args
17+
*/
18+
publicstaticvoidmain(String[]args) {
19+
// JDK13之前
20+
Stringhtml ="<html>\n" +
21+
" <body>\n" +
22+
" <p>Hello, world</p>\n" +
23+
" </body>\n" +
24+
"</html>\n";
25+
26+
// JDK13之后
27+
Stringhtml2 ="""
28+
<html>
29+
<body>
30+
<p>Hello, world</p>
31+
</body>
32+
</html>
33+
""";
34+
}
35+
36+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp