Which methods are being used as an abstract method for functional interface?

Looking under the java built in interface, Comparator<T> functional interface has 2 non default methods, int compare(T o1, T o2) and boolean equals(Object obj). My question is asking the reason of why the latter method does not need to be implemented when using lambda/anonymous, what determines which method is being used as the functional method within the interface. As of what I understand, functional interface may only take one abstract method to be implemented, but how does it know which method is needed to be implemented during an anonymous class/lambda calls? My logic is that Comparator takes generic T, so that it find the following abstract method that uses T as the parameters, such as int compare(T o1, T o2). OR in another case, because of the order of method declaration.
No description
4 Replies
JavaBot
JavaBot12mo ago
This post has been reserved for your question.
Hey @circle! Please use /close or the Close Post button 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.
dan1st
dan1st12mo ago
equals is defined in Object
circle
circleOP12mo ago
Oh my bad, that makes sense. 😂
JavaBot
JavaBot12mo ago
Post Closed
This post has been closed by <@389034898666553344>.
Want results from more Discord servers?
Add your server