Search the courses, subjects, tracks, games and features, or jump straight to a page.
2 cards from this section. Quick, good the night before a test.
What does it mean for a variable to be effectively final?
Think about how the variable is used in a lambda.
Can you use a variable that is modified after its declaration inside a lambda?
Consider the definition of effectively final.
What is an effectively final variable?
Reflect on the term 'effectively'.
Can a lambda modify local variables in its enclosing scope?
Think about the rules that restrict what lambdas can access.
Create a Java program that uses a lambda to sum the values of an array while trying to modify a local counter inside the lambda. What errors arise?
Check what happens to any counter variable if you try to redefine it in the lambda.
Illustrate with code how an effectively final variable can be used in a sorting lambda while clarifying why a non-final variable cannot be used.
Experiment with creating two different versions of the same functionality.
4 more questions in this section. Enroll free to practise them all.
Enroll free