I saw following block of code in my teams codebase :
boolean value = fun(data->{
data.setProperty();
return data;
})
Above fun is a method which accepts objects of class called Data. However I have doubt:
I just saw data object only passed inside fun i.e there was no line of code like Data data = new Data() before above code snippet. Thus how above code snippet works ? It looks similar to lambda or anonymous functions. But I have never seen such code block in Java before. data object was present in whole .java file at only one place and that was above code block. I got curius how it's possible to use some object variable without declaring before.