forked from mitocode21/java8mito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScopes.java
More file actions
52 lines (38 loc) · 972 Bytes
/
Copy pathScopes.java
File metadata and controls
52 lines (38 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.mitocode.lambda;
public class Scopes {
private static double atributo1;
private double atributo2;
public double probarLocalVariable(){
final double n3 = 3;
Operacion op = new Operacion(){
@Override
public double calcular(double n1, double n2) {
return n1 + n2 + n3;
}
};
Operacion operacion = (x,y) -> {
return x + y + n3;
};
return operacion.calcular(1,1);
}
public double probarAtributosStaticVariables(){
Operacion op = new Operacion(){
@Override
public double calcular(double n1, double n2) {
atributo1 = n1 + n2;
atributo2 = atributo1;
return atributo2;
}
};
Operacion operacion = (x, y) -> {
atributo1 = x + y;
atributo2 = atributo1;
return atributo2;
};
return operacion.calcular(3, 2);
}
public static void main(String... mitocode) {
Scopes app = new Scopes();
System.out.println(app.probarAtributosStaticVariables());
}
}