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

Commit81a0fa3

Browse files
committed
Java 11 local variable samples
1 parent093d9a4 commit81a0fa3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
packagecom.winterbe.java11;
2+
3+
importjava.util.ArrayList;
4+
importjava.util.List;
5+
importjava.util.Map;
6+
importjava.util.function.Predicate;
7+
8+
publicclassLocalVariableSyntax {
9+
10+
publicstaticvoidmain(String[]args) {
11+
vartext ="Banana";
12+
// Incompatible types:
13+
// text = 1;
14+
15+
16+
// Cannot infer type:
17+
// var a;
18+
// var nothing = null;
19+
// var bla = () -> System.out.println("Hallo");
20+
// var method = LocalVariableSyntax::someMethod;
21+
22+
varlist1 =newArrayList<>();// ArrayList<Object>
23+
24+
varlist2 =newArrayList<Map<String,List<Integer>>>();
25+
26+
for (varcurrent :list2) {
27+
// current is of type: Map<String, List<Integer>>
28+
System.out.println(current);
29+
}
30+
31+
Predicate<String>predicate1 = (@Deprecatedvara) ->false;
32+
33+
}
34+
35+
voidsomeMethod() {}
36+
37+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp