FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
OnJava8-Examples/functional/Closure8.java at master · CSapprenticeWT/OnJava8-Examples · GitHub
CSapprenticeWT
OnJava8-Examples
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
OnJava8-Examples
/
functional
/
Closure8.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (31 loc) · 735 Bytes
Breadcrumbs
OnJava8-Examples
/
functional
/
Closure8.java
Copy path
File metadata and controls
32 lines (31 loc) · 735 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
// functional/Closure8.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import
java
.
util
.*;
import
java
.
util
.
function
.*;
public
class
Closure8
{
Supplier
<
List
<
Integer
>>
makeFun
() {
final
List
<
Integer
>
ai
=
new
ArrayList
<>();
ai
.
add
(
1
);
return
() ->
ai
;
}
public
static
void
main
(
String
[]
args
) {
Closure8
c7
=
new
Closure8
();
List
<
Integer
>
l1
=
c7
.
makeFun
().
get
(),
l2
=
c7
.
makeFun
().
get
();
System
.
out
.
println
(
l1
);
System
.
out
.
println
(
l2
);
l1
.
add
(
42
);
l2
.
add
(
96
);
System
.
out
.
println
(
l1
);
System
.
out
.
println
(
l2
);
}
}
/* Output:
[1]
[1]
[1, 42]
[1, 96]
*/
Back
|
FazBrowse Home
|
New Git URL