Employers: discover CodinGame for tech hiring
CodinGame - Home
ACTIVITIES
PRACTICE
COMPETE
COOPERATE
LEARN
EVENTS
COMMUNITY
CONTRIBUTIONS
LIVE STREAMS
DISCORD
FORUMS
BLOG
Get a job
1
1
Log In
Sign Up
Java Streams CheatSheet
devv
4,834 views
Streams
Effectively final variable.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// {
class Main {
public static void main(String[] args) {
// }
//Incorrect
for (int i = 0; i < 10; i++) {
new Thread(() -> {
System.out.println("i = " + i); // Does not c
ompile!
}).start();
}
// {
}
}
// }
Run
1
2
3
4
5
6
7
8
9
10
11
12
13
// {
class Main {
public static void main(String[] args) {
// }
for (int i = 0; i < 10; i++) {
int j = i; //effectively final
new Thread(() -> System.out.println("i
= " + j)).start();
}
// {
}
}
// }
Run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// {
class Main {
public static void main(String[] args) {
// }
//Incorrect
for (int i = 0; i < 10; i++) {
int j = i;
new Thread(() -> System.out.println("i = " + j
)).start();
j++;
}
// {
}
}
// }
Run
11
0
Create your playground on Tech.io
This playground was created on Tech.io, our hands-on, knowledge-sharing platform for developers.
Go to tech.io
Suggested playgrounds
Stream sum of evens in Java
By
Daxlo
3,320
22
3
Java Guild Meeting 5/2018
By
Gi11i4m
38.4K
33
9
Java 9 Improvements
By
RunninglVlan
23.4K
39
2
Java 8 Stream Tutorial
By
devv
14.1K
63
2
CodinGame - Home
ABOUT US
CAREERS
PRIVACY
FAQ
CodinGame - Work
The #1 tech hiring platform
SCREENING
SOURCING
RETAIN
ABOUT US
CAREERS
PRIVACY
FAQ
Facebook
YouTube
Twitter
LinkedIn
FR
EN
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants
Keyboard Shortcuts:
?
Show / hide this help menu
×