#Functional Interface vs Functions
10 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @crisp abyss! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
well, the issue is you can't
methods in java can't be referenced or passed around directly, they aren't first-class members
functional interfaces let you create objects (which are first-class members) that represent the method, so you can work around that limitation of the language
in practice, that's utilized in callbacks, ie functions that you provide to some other method, where the method can either call the function after doing something or with data, or use that function to integrate in some other task
lambdas are a syntax to implement functional interfaces; they're just syntactic sugar
before lambdas were introduced (in java 8 or 9, don't remember), anonymous classes implementing the respective interface were used (SAMs for Single Abstract Method, i believe? not sure on the terminology since it's not used much anymore)
I understand, thanks a lot! Was really confused at first :)
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.