File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .winterbe .java11 ;
2+
3+ import java .util .ArrayList ;
4+ import java .util .List ;
5+ import java .util .Map ;
6+ import java .util .function .Predicate ;
7+
8+ public class LocalVariableSyntax {
9+
10+ public static void main (String [] args ) {
11+ var text = "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+ var list1 = new ArrayList <>(); // ArrayList<Object>
23+
24+ var list2 = new ArrayList <Map <String , List <Integer >>>();
25+
26+ for (var current : list2 ) {
27+ // current is of type: Map<String, List<Integer>>
28+ System .out .println (current );
29+ }
30+
31+ Predicate <String > predicate1 = (@ Deprecated var a ) -> false ;
32+
33+ }
34+
35+ void someMethod () {}
36+
37+ }
You can’t perform that action at this time.
0 commit comments