Illuminatiiiiii
11/11/2018 - 7:19 PM

Effectively Final(Variable Capture)

For Episode 66 of the Java Series: https://youtu.be/um8GVlfmTH8

interface FunctionalInterface{
    int func(int a);
}
public class Main {

    public static void main(String[] args){

        //A Random variable. 
        int thing = 25;
        
        FunctionalInterface ez = (int a) -> {
            int result;
            result = thing * a; //Since we used the variable thing, it's now been captured. This makes it effectively final.
            
            //thing = 34; We cannot do this because the variable is now effectively final, meaning it's a constant.
            return result;
        };
        
        //thing = 24; //Also cannot be changed out here, the lambda made it final

    }
}