1

Since I have an interface with two methods, how do I implement it with a concrete class? How do I write Lambda expressions for these two methods?

 interface LambdaExpression {
     void methodA();
     void methodB();
 }
5
  • 4
    Your interface is not a functional interface Commented Jan 21, 2018 at 16:59
  • @AndreyTyukin, please don't edit out proper grammar and/or punctuation. You've made this nearly unreadable. Commented Jan 21, 2018 at 17:13
  • @ChiefTwoPencils Sorry, there was a race condition between the two edits, for some reason "the system" decided to take my (less elaborate) edit. I didn't even attempt to fix the grammar or add any punctuation in this one. Could one roll it back to your version somehow, I agree that your version made much more sense. Commented Jan 21, 2018 at 17:17
  • No worries @AndreyTyukin. I think you can roll yours back if you want. Commented Jan 21, 2018 at 17:19
  • @ChiefTwoPencils ok, rolled back to your version, additionaly changed "Experession" to "Expression". [cleaning up the comment section] Commented Jan 21, 2018 at 17:30

1 Answer 1

3

You can not. Lambda expressions are for functional interfaces ie interface with only one abstract method.

Sign up to request clarification or add additional context in comments.

3 Comments

What are solutions for this case in Java 8
@WaseemSaeed: create two interfaces with one abstract method each.
Thanks @Anurag That is the only solution I guess. Thanks, Mate.!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.