blob: a30492ac820a86bbfccd6503d032f4b03d106e4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import lombok.experimental.var;
public class VarComplex {
private String field = "";
private static final int CONSTANT = 20;
public void testComplex() {
var shouldBeCharArray = field.toCharArray();
var shouldBeInt = CONSTANT;
var lock = new Object();
synchronized (lock) {
var field = 20; //Shadowing
var inner = 10;
switch (field) {
case 5:
var shouldBeCharArray2 = shouldBeCharArray;
var innerInner = inner;
}
}
var shouldBeString = field; //Unshadowing
}
}
|